<%@page import="com.sq.partner.manager.util.StrUtil"%>
<%@page import="java.sql.Struct"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<% String path=request.getContextPath(); String basePath=request.getScheme()+ "://" + request.getServerName() + ":" + request.getServerPort() + path+ "/"; %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head>
<base href="<%=basePath%>">
<title>投保方案新增</title>
<%@ include file="/WEB-INF/jsp/common/common.jsp" %>
<style type="text/css">
.input_text{width:180px;}
.select_1{width:180px;}
#agentType3Table{
	 margin: auto;
}
#agentType4Table{
	 margin: auto;
}
#agentType3Table td{
	border: 1px solid #bbcddb;
	height:15px; 
	line-height:15px;
}
#agentType4Table td{
	border: 1px solid #bbcddb;
	height:15px; 
	line-height:15px;
}
</style>
<script src="js/jquery.validate.js" type="text/javascript" ></script>
<script src="js/jquery.divbox.js" type="text/javascript"></script>
<script src="js/json2.js" type="text/javascript"></script>
<script type="text/javascript">
//自定义map功能
function Map(){
  this.elements = new Array();
   //获取MAP元素个数
   this.size = function() {
       return this.elements.length;
   };
   //判断MAP是否为空
   this.isEmpty = function() {
       return (this.elements.length < 1);
   };
   //删除MAP所有元素
   this.clear = function() {
       this.elements = new Array();
   };
   //向MAP中增加元素（key, value)
   this.put = function(_key, _value) {
       if(this.containsKey(_key)){
        this.remove(_key);
        this.elements.push( {
           key : _key,
           value : _value
        });
       }else{
        this.elements.push( {
           key : _key,
           value : _value
        });
       }  
   };
   //删除指定KEY的元素，成功返回True，失败返回False
   this.remove = function(_key) {
       var bln = false;
       try {
           for (var i = 0; i < this.elements.length; i++) {
               if (this.elements[i].key == _key) {
                   this.elements.splice(i, 1);
                   return true;
               }
           }
       } catch (e) {
           bln = false;
       }
       return bln;
   };
   //获取指定KEY的元素值VALUE，失败返回NULL
   this.get = function(_key) {
       try {
           for (var i = 0; i < this.elements.length; i++) {
               if (this.elements[i].key == _key) {
                   return this.elements[i].value;
               }
           }
       } catch (e) {
           return false;
       }
       return false;
   };
   //判断MAP中是否含有指定KEY的元素
   this.containsKey = function(_key) {
       var bln = false;
       try {
           for (var i = 0; i < this.elements.length; i++) {
               if (this.elements[i].key == _key) {
                   bln = true;
               }
           }
       } catch (e) {
           bln = false;
       }
       return bln;
   };
  //获取map的所有values
  this.values = function() {
       var arr = new Array();
       for (var i = 0; i < this.elements.length; i++) {
           arr.push(this.elements[i].value);
       }
       return arr;
   };
  //获取map的所有keys
  this.keys= function() {
       var arr = new Array();
       for (var i = 0; i < this.elements.length; i++) {
           arr.push(this.elements[i].key);
       }
       return arr;
   };
   //获取数组
   this.getArray= function(){
   	var arr = new Array();
   	for (var i = 0; i < this.elements.length; i++) {
           arr.push({
	            key : this.elements[i].key,
	            value : this.elements[i].value
	         });
       }
       return arr;
   };
}
//-------------页面开始----------
var poolType = 0;
var prodAppType='';
var agentTypeList = new Array();
var map = new Map();
var mapBak = new Map();
var realClientNo = '${realClientNo}';
//------------------------------------------ 初始化本页面 开始----------------------------------------------
<%
String pno = "";
if(null != request.getAttribute("insuPlanNo")){
	pno = request.getAttribute("insuPlanNo").toString();
	System.out.print("================================================"+(StrUtil.isNotEmpty(pno)));
}
if(StrUtil.isNotEmpty(pno)){
%>
$(document).ready(function(){
	var insplanno = $('#hidepno').val();
	init(insplanno);
	$("#sbtn").attr("onclick","").unbind("click").click(function(){  
		checkAndExcute('update');
	}); 	

	prodAppType = ${appType};
	<%
	String poolType = "0";
	if(null != request.getAttribute("poolTypeVal")){
		poolType = request.getAttribute("poolTypeVal").toString();
	%>
		poolType = ${poolTypeVal};
		
		<%}if("0".equals(poolType)){%>
		$('#poolColumns1').css('display','none');
		$('#poolColumns2').css('display','none');
		$('#poolColumns3').css('display','none');
		$('#poolColumns4').css('display','none');
		$('#poolColumns5').css('display','none');
	<%}else{%>
		$('#poolColumns1').css('display','');
		$('#poolColumns2').css('display','');
		$('#poolColumns3').css('display','');
		$('#poolColumns4').css('display','');
		$('#poolColumns5').css('display','');
	<%}%>	
	
	var myselect=document.getElementById("newBsnsType");
	var index=myselect.selectedIndex;
	var index2=myselect.options[index].text;
	if(index2.indexOf("直销")>=0){
		$("#agent_no").val("");
		$("#agent_no").attr("disabled",true);
		$("#protocol_no").val("");
		$("#protocol_no").attr("disabled",true);
		document.getElementById("agent_no").style.cssText="background-color: #ccc;";
		document.getElementById("protocol_no").style.cssText="background-color: #ccc;";
	}else{
		$("#agent_no").attr("disabled",false);
		$("#protocol_no").attr("disabled",false);
		document.getElementById("agent_no").style.cssText="none;";
		document.getElementById("protocol_no").style.cssText="none;";
	}
		
})
<%
}
%>


function init(insplanno){
	$.ajax({
		url : "insure/loadInsuPlanInfo",
		type : 'POST',
		async : false,
		data:{insuPlanNo:insplanno},
		dataType:'json',
		success:function(data){
			if(data.message==undefined){
				$('#insu_plan_no').val(data.INSUPLANNO);
				$('#insu_plan_name').val(data.INSUPLANNAME);
				$('#prodInstCode').val(data.TRADPRODCODE);
				$('#instCode').val(data.PARTNERNO);
				
				$('#channelCodeQD').val(data.CHANNLECODE);
				$('#channelType').val(data.CHANNLETYPE);
				$('#newBsnsType').val(data.NEWBSNSTYPE);
				$('#bsnsType').val(data.CATEGORYCODE);
				if("19002"!=data.CATEGORYCODE&&"19003"!=data.CATEGORYCODE){
					$("#agent_no ~ span").remove(".red");
					$("#protocol_no ~ span").remove(".red");
				}
				
				$('#comm_rate').val(data.COMMRATE);
				//1、合作伙伴代理3、个人代理4、总对总代理
				if("1"==data.AGENTTYPE){
					$('#agent_no').val(data.AGENTNO);
					$('#protocol_no').val(data.PROTOCOLNO);
					$('#service_code').val(data.SERVICECODE);
					$('#emp_no').val(data.EMPNO);
					$('#team_code').val(data.TEAMCODE);
					$('#team_name').val(data.TEAMNAME);
					$("tr[id^=qudaoandlaiyuan0]").css('display','');
					$("tr[id^=agentType1]").css('display','');
					$("tr[id^=agentType3]").css('display','none');
					$("tr[id^=agentType4]").css('display','none');
					$("#deptCode101").empty();
					$("#deptCode102").empty();
					$("#deptCode101").append("出单机构：");
					$("#deptCode102").append("<input id='dptCode'  type='text' readonly='readonly' style=' background-color: #ccc;' class='input_text'><span class='red'>*</span>&nbsp;<input type='button'  class='input_button_2' id='searchDeptBtn' value='请选择' onClick='openDeptDiv(1,this)' />");
					$('#dptCode').val(data.DPTCDE);
				}else if("3"==data.AGENTTYPE){
					$("#cardApplicant_div").css('display','none');
					queryConfProxyInfoEdit3(1);
					mapBak.clear();//清空备份map
					for(var o in data.map){  
			        	var obj = new Object();
			        	obj.id = data.map[o].id=="null"?"":data.map[o].id;
			        	obj.cardapplicant = data.map[o].cardapplicant=="null"?"":data.map[o].cardapplicant;
			        	obj.value = data.map[o].value=="null"?"":data.map[o].value;
			        	map.put(obj.id,obj);
			        	mapBak.put(obj.id,obj);
			      	}
					$("#agentType").val(data.AGENTTYPE);
					$("tr[id^=qudaoandlaiyuan0]").css('display','none');
					$("tr[id^=agentType1]").css('display','none');
					$("tr[id^=agentType3]").css('display','');
					$("tr[id^=agentType4]").css('display','none');
					$("#deptCode101").empty();
					$("#deptCode102").empty();
					$("#deptCode102").append("<input type='hidden' id='dptCode' value='' />");
				}else if("4"==data.AGENTTYPE){
					$("#cardApplicant_div").css('display','none');
					queryConfProxyInfoEdit4(1);
					mapBak.clear();//清空备份map
					for(var o in data.map){  
			        	var obj = new Object();
			        	obj.id = data.map[o].id=="null"?"":data.map[o].id;
			        	obj.cardapplicant = data.map[o].cardapplicant=="null"?"":data.map[o].cardapplicant;
			        	obj.value = data.map[o].value=="null"?"":data.map[o].value;
			        	map.put(obj.id,obj);
			        	mapBak.put(obj.id,obj);
			      	}
					$("#agentType").val(data.AGENTTYPE);
					$("tr[id^=qudaoandlaiyuan0]").css('display','none');
					$("tr[id^=agentType1]").css('display','none');
					$("tr[id^=agentType3]").css('display','none');
					$("tr[id^=agentType4]").css('display','');
					$("#deptCode101").empty();
					$("#deptCode102").empty();
					$("#deptCode102").append("<input type='hidden' id='dptCode' value='' />");
				}else{
					$('#agent_no').val(data.AGENTNO);
					$('#protocol_no').val(data.PROTOCOLNO);
					$('#service_code').val(data.SERVICECODE);
					$('#emp_no').val(data.EMPNO);
					$('#team_code').val(data.TEAMCODE);
					$('#team_name').val(data.TEAMNAME);
					$("tr[id^=qudaoandlaiyuan0]").css('display','');
					$("tr[id^=agentType1]").css('display','');
					$("tr[id^=agentType3]").css('display','none');
					$("tr[id^=agentType4]").css('display','none');
					$("#deptCode101").empty();
					$("#deptCode102").empty();
					$("#deptCode101").append("出单机构：");
					$("#deptCode102").append("<input id='dptCode'  type='text' readonly='readonly' style=' background-color: #ccc;' class='input_text'><span class='red'>*</span>&nbsp;<input type='button'  class='input_button_2' id='searchDeptBtn' value='请选择' onClick='openDeptDiv(1,this)' />");
					$('#dptCode').val(data.DPTCDE);
				}
				<%-- added by gzz@20150824 begin--%>
				if("" != realClientNo){
					$("#applicant_no").prepend('<option value='+realClientNo+'>'+realClientNo+'</option>');
				}
				<%-- added by gzz@20150824 end--%>
				$('#applicant_no').attr('value',data.APPLICANTNO);
				$('#is_message').val(data.ISMESSAGE);
				if(data.ISMESSAGE=='Y'){
					$('#messageTemplateTr').show();
					//$('#messageTemplate').css("background-color","white");
					$('#messageTemplate').attr("disabled",true).css("background-color","rgb(204, 204, 204)").val(data.messageTemplate_val);
					$("#smsTemplateDiv").show();
					$('#smsTemplate').val(data.MESSAGETEMPLATE);
					//$('#messageTemplate').val(data.MESSAGETEMPLATE);
					$('#messageReceiverDiv').show();
					$('#messageReceiver').val(data.MESSAGERECEIVER);
				}
				$('#is_receipt').val(data.ISRECEIPT);//wangyan 2015年6月1日13:35:08 add 是否回执
				$('#receiptType').val(data.RECEIPTTYPE);
				chooseReceiptType();
				$('#state').val(data.STATE);
				$('#special_arran').val(data.SPECIALARRAN);
				$('#isSeeMoney').val(data.ISSEEMONEY);
				if($('#isSeeMoney').val()==2){
					$('#isDredgePay').attr("disabled",true);
					$("#isDredgePay").css({"background-color": "#ccc"});
				}else{
					$("#isDredgePay").attr("disabled",false);
					$("#isDredgePay").css({"background-color": ""});
				}
				if(data.EPOLICYINVOICE==''||data.EPOLICYINVOICE==null){
					$('#isEpolicyInvoice').val(2);
				}else{
					$('#isEpolicyInvoice').val(data.EPOLICYINVOICE);
				}
				
				if(data.DREDGEPAY==''||data.DREDGEPAY==null){
					$('#isDredgePay').val(2);
				}else{
					$('#isDredgePay').val(data.DREDGEPAY);
				}
				
				//注销短信模板、短信接收人动态显示
				$('#isCancelMessage').val(data.ISCANCELMESSAGE);
				if(data.ISCANCELMESSAGE=='Y'){
					$('#cancelTemplateTr').show();
					$('#cancelTemplate').css("background-color","white");
					//$('#cancelTemplate').val(data.CANCELTEMPLATE);
					$('#cancelTemplate').val(data.cancelTemplate_val);
					$('#cancelReceiverDiv').show();
					$('#cancelReceiver').val(data.CANCELRECEIVER);
					$('#cancelTemplateDiv').show();
					$('#isCancelTemplate').val(data.CANCELTEMPLATE);
					$("#cancelTemplate").attr("disabled",true).css("background-color","rgb(204, 204, 204)");
				}
				//是不是发送邮件
				if(data.EPOLICYMALI==''||data.EPOLICYMALI==null){
					$('#isEpolicyMali').val(2);
				}else{
					$('#isEpolicyMali').val(data.EPOLICYMALI);
				}
				if((data.EPOLICYMALI)==0||(data.EPOLICYMALI)==2){
					$('#MailTemplateTr').hide();
					$('#sendAccessory').hide();
					$('#sendAccessoryTd').hide();
				}
				if((data.EPOLICYMALI)=="1"){
					$('#sendAccessory').show();
					$('#sendAccessoryTd').show();
					$('#MailTemplateTr').show();
					var ids=new Array(5);
					ids=data.ids;
					if(ids!=null){
						$('input[name=SendAccessoryBox]').each(function(){
							for(i=0;i<ids.length;i++){
								if($(this).val()==ids[i]){
									$(this).attr("checked",true);
								}
							}
						});
					}
				}
				//是不是发送电子保单
				$('#isEpolicy').val(data.ISEPOLICY);
				if((data.ISEPOLICY)=="Y"){
					$('#Download_left').val(data.ISEPOLICY);
					$('#Download_right').show();
					$('#DownloadWay').show();
				}else{
					//rt(12312)
					$('#Download_left').val(data.ISEPOLICY);
					$('#Download_right').hide();
				}
				
				
				$('#DownloadWay').val(data.DOWNLOADWAY);
				downloadWayChange();
				$('#fileType').val(data.FILETYPE);
				$('#MailTemplate').html(data.MAILTEMPLATE);   
				$('#poolInsureCompany').val(data.POOLINSURECOMPANY);
				$('#poolProcotol').val(data.POOLPROCOTOL);
				if(null!=data.POOLRATE){
					$('#poolRate').val(data.POOLRATE*1000);
				}
				$('#poolAgentRate').val(data.POOLAGENTRATE);
				$('#poolInsureAmount').val(data.POOLINSUREAMOUNT);
				$('#poolIssueFlag').val(data.POOLISSUEFLAG);
				$('#poolProcotolNo').val(data.POOLPROCOTOLNO);
				$('#poolRole').val(data.POOLROLE);
				$('#reminder').val(data.NOTICE);
				if(null!=data.ISPRINTCARD){
					$('#isPrintCard').val(data.ISPRINTCARD);
					if(data.ISPRINTCARD=='0'){
						$('#cardApplicant').attr("readonly",false);
						$('#cardApplicant').css("background-color","white");
						$('#cardApplicant').val(data.CARDAPPLICANT);
						$('#cardType').attr("readonly",false);
						$('#cardType').css("background-color","white");
						$('#cardType').val(data.CARDTYPE);
					}
				}
			}else{
				$.message("error", "页面加载失败");
			}
       	}
	});
}
//当“是否发送短信”的值为“是”时，短信模板配置可输入
function changeIsCancelMessage(){
	var isMessage = $.trim($('#isCancelMessage').val());
	if(isMessage =='Y'){
		$('#cancelReceiverDiv').show();
		$('#cancelTemplateTr').show();
		$('#cancelTemplateDiv').show();
		//$('#cancelTemplate').css("background-color","white");
		$("#cancelTemplate").attr("disabled",true).css("background-color","rgb(204, 204, 204)");
	}else{
		$('#cancelReceiverDiv').hide();
		$('#cancelTemplateTr').hide();
		$('#cancelTemplateDiv').hide();
		$('#cancelTemplate').val('');
		$("#isCancelTemplate").val('');
	}
}
//绑定单选按钮事件，选中某个单选按钮，该按钮所在行高亮显示
function bindradio(){
	$("input[name='prodradio']").click(function(){
		$("input[name='prodradio']").parent().parent().removeClass("table_highlighter");
		$(this).parent().parent().addClass("table_highlighter");
   	});
	$("input[name='partnerradio']").click(function(){
		$("input[name='partnerradio']").parent().parent().removeClass("table_highlighter");
		$(this).parent().parent().addClass("table_highlighter");
   	});
	$("input[name='deptradio']").click(function(){
		$("input[name='deptradio']").parent().parent().removeClass("table_highlighter");
		$(this).parent().parent().addClass("table_highlighter");
   	});
	$("input[name='agentType3checkbox']").click(function(){
		var id= $(this).parent().parent().children(" td:eq(1)").html();
		if($(this).prop("checked")){//选中
			$(this).parent().parent().addClass("table_highlighter");
			var obj = new Object();
			var cardapplicant= $(this).parent().parent().children(" td:eq(7)").html();
			var value= $(this).parent().parent().find("input[name='value']").val();
			obj.id =id;
			obj.cardapplicant = cardapplicant;
			obj.value= value;
			map.put(obj.id,obj);
		}else{//取消选中
			$(this).parent().parent().removeClass("table_highlighter");
			$(this).prop("checked",false);
			map.remove(id);
		}
   	});
	$("input[name='agentType4checkbox']").click(function(){
		var id= $(this).parent().parent().children(" td:eq(1)").html();
		if($(this).prop("checked")){//选中
			$(this).parent().parent().addClass("table_highlighter");
			var obj = new Object();
			   var columnes=$("#agentTypeDiv4Table").find("th").length;
				if(columnes==16){
					obj.cardapplicant = $(this).parent().parent().children(" td:eq(10)").html();
				}else if(columnes==18){
					obj.cardapplicant = $(this).parent().parent().children(" td:eq(12)").html();
				}
			var value= $(this).parent().parent().find("input[name='value']").val();
			obj.id =id;
			obj.value= value;
			map.put(obj.id,obj);
		}else{//取消选中
			$(this).parent().parent().removeClass("table_highlighter");
			$(this).prop("checked",false);
			map.remove(id);
		}
   	});
	$("#agentTypeDiv3CheckAll").click(function(){
		if($(this).prop("checked")){//选中
			$("#agentTypeDiv3Table tbody tr").each(function() {
				$(this).find("input[name='agentType3checkbox']").prop("checked",true);
				$(this).addClass("table_highlighter");
				var obj = new Object();
				var id= $(this).children(" td:eq(1)").html();
				var cardapplicant= $(this).children(" td:eq(7)").html();
				var value= $(this).find("input[name='value']").val();
				obj.id =id;
				obj.cardapplicant = cardapplicant;
				obj.value= value;
				map.put(obj.id,obj);
			});
		}else{//取消选中
			$("#agentTypeDiv3Table tbody tr").each(function() {
				$(this).removeClass("table_highlighter");
				$(this).find("input[name='agentType3checkbox']").prop("checked",false);
				var id= $(this).children(" td:eq(1)").html();
				map.remove(id);
			});
		}
	});
	$("#agentTypeDiv4CheckAll").click(function(){
		if($(this).prop("checked")){//选中
			$("#agentTypeDiv4Table tbody tr").each(function() {
				$(this).find("input[name='agentType4checkbox']").prop("checked",true);
				$(this).addClass("table_highlighter");
				var obj = new Object();
				var id= $(this).children(" td:eq(1)").html();
				var columnes=$("#agentTypeDiv4Table").find("th").length;
				if(columnes==16){
					obj.cardapplicant = $(this).parent().parent().children(" td:eq(10)").html();
				}else if(columnes==18){
					obj.cardapplicant = $(this).parent().parent().children(" td:eq(12)").html();
				}
			
				var value= $(this).find("input[name='value']").val();
				obj.id =id;
				obj.value= value;
				map.put(obj.id,obj);
			});
		}else{//取消选中
			$("#agentTypeDiv4Table tbody tr").each(function() {
				$(this).removeClass("table_highlighter");
				$(this).find("input[name='agentType4checkbox']").prop("checked",false);
				var id= $(this).children(" td:eq(1)").html();
				map.remove(id);
			});
		}
	});
	
}
//------------------------------------------ 初始化本页面 结束----------------------------------------------

//统一 关闭  窗口
function closeCurrentDIV(obj){
	$("#"+obj).CloseDiv();	
}

//------------------------------------------ 产品  开始----------------------------------------------
//打开产品窗口
function openProdDiv(pageIndex,obj){
	$('#prodcode').val('');
	$('#proddesc').val('');
	$('#startDate').val('');
	$('#endDate').val('');

	$("#"+obj.id).blur();
	queryTradProdInst(pageIndex);
}

//调用拼接参数的方法，并执行查询
function queryTradProdInst(pageIndex){
	var size = 8;
	var code = $('#prodcode').val();
	var desc = $('#proddesc').val();
	var strReg = /^(\d{4})\-(\d{2})\-(\d{2})$/;
	var startDate = $('#startDate').val();
	var endDate = $('#endDate').val();
	var sflag = strReg.test(startDate);
	var eflag = strReg.test(endDate);
	if(null != startDate && "" != startDate){
		if(!sflag){
			$.message("error", "您输入的定义起期格式不正确，格式为：YYYY-MM-DD。请重新选择日期");
			$('#startDate').val('');
			return;
		}
	}
	if(null != endDate && "" != endDate){
		if(!eflag){
			$.message("error", "您输入的定义止期格式不正确，格式为：YYYY-MM-DD。请重新选择日期");
			$('#endDate').val('');
			return;
		}
	}
	queryAllProds({size:size,pageIndex:pageIndex,tradProdCode:code,tradProdDesc:desc,VstartDate:startDate,VendDate:endDate});
}


//查询产品
function queryAllProds(param){
	$.openLoading();
	$.ajax({
		url : "insure/loadTradProdInst",
		type : 'POST',
		async : true,
		data:param,
		dataType:'json',
		success:function(partnerPage){
			$.closeLoading();
			if(partnerPage.result=="fail"){
				$.message("error",partnerPage.message);

        		return;
        	}

			var radioObj ="<input class='input_fxk' name='prodradio' type='radio' value=''>";
			var fieldNames = "tradProdCode,tradProdDesc,poolType@TDH,tradAppType@TDH,agentType@TDH";
			var tableContent = creatTable1(fieldNames,partnerPage,radioObj);
			var tableObj = $("#productTable");
			tableObj.find("tbody").remove();
			tableObj.append(tableContent);
			
			var strPage = creatChannelPage(param.pageIndex,6,partnerPage.maxPage,"17");
			var pageDIV = $("#productPageDIV");
			pageDIV[0].innerHTML="";
			pageDIV.append(strPage);
			
			$("#prodDiv").OpenDiv();

			bindradio();
		}
	});
}

//点击“确定” ，选择 产品
function chooseProd(){
	var selectedProd= $("input[name='prodradio']:checked");
	if(selectedProd.length==0){
		$.message("error", "请选择一个产品");
		return;
	}
	var prodCode = selectedProd.parent().parent().children(" td:eq(1)").html();//产品代码
	$('#prodInstCode').val(prodCode);
	
	//产品投保类型 ，0：个单；1：团单
	prodAppType = selectedProd.parent().parent().children(" td:eq(4)").html();
	
	//产品的共保类型
	poolType = selectedProd.parent().parent().children(" td:eq(3)").html();
	if(poolType==0){
		$('#poolColumns1').css('display','none');
		$('#poolColumns2').css('display','none');
		$('#poolColumns3').css('display','none');
		$('#poolColumns4').css('display','none');
		$('#poolColumns5').css('display','none');
	}else{
		$('#poolColumns1').css('display','');
		$('#poolColumns2').css('display','');
		$('#poolColumns3').css('display','');
		$('#poolColumns4').css('display','');
		$('#poolColumns5').css('display','');
	}
	var agentType = selectedProd.parent().parent().children(" td:eq(5)").html();//销售类型
	$("#agentType").val(agentType);
	//1、合作伙伴代理3、个人代理4、总对总代理
	if('1'==agentType){
		$("tr[id^=qudaoandlaiyuan0]").css('display','');
		$("#cardApplicant_div").css('display','');
		$("tr[id^=agentType1]").css('display','');
		$("tr[id^=agentType3]").css('display','none');
		$("tr[id^=agentType4]").css('display','none');
		$("#commRateSpan").empty();
		$("#deptCode101").empty();
		$("#deptCode102").empty();
		$("#deptCode101").append("出单机构：");
		$("#deptCode102").append("<input id='dptCode'  type='text' readonly='readonly' style=' background-color: #ccc;' class='input_text'><span class='red'>*</span>&nbsp;<input type='button'  class='input_button_2' id='searchDeptBtn' value='请选择' onClick='openDeptDiv(1,this)' />");
	}else if('3'==agentType){
		$("tr[id^=qudaoandlaiyuan0]").css('display','none');
		$("#cardApplicant_div").css('display','none');
		$("tr[id^=agentType1]").css('display','none');
		$("tr[id^=agentType3]").css('display','');
		$("tr[id^=agentType4]").css('display','none');
		$("#commRateSpan").empty();
		$("#commRateSpan").append("销售业务信息未配置,则使用此比例");
		$("#deptCode101").empty();
		$("#deptCode102").empty();
		$("#deptCode102").append("<input type='hidden' id='dptCode' value='' />");
	}else if('4'==agentType){
		$("tr[id^=qudaoandlaiyuan0]").css('display','none');
		$("#cardApplicant_div").css('display','none');
		$("tr[id^=agentType1]").css('display','none');
		$("tr[id^=agentType3]").css('display','none');
		$("tr[id^=agentType4]").css('display','');
		$("#commRateSpan").empty();
		$("#commRateSpan").append("销售业务信息未配置,则使用此比例");
		$("#deptCode101").empty();
		$("#deptCode102").empty();
		$("#deptCode102").append("<input type='hidden' id='dptCode' value='' />");
	}else{
		$("tr[id^=qudaoandlaiyuan0]").css('display','');
		$("#cardApplicant_div").css('display','none');
		$("tr[id^=agentType1]").css('display','');
		$("tr[id^=agentType3]").css('display','none');
		$("tr[id^=agentType4]").css('display','none');
		$("#commRateSpan").empty();
		$("#deptCode101").empty();
		$("#deptCode102").empty();
		$("#deptCode101").append("出单机构：");
		$("#deptCode102").append("<input id='dptCode'  type='text' readonly='readonly' style=' background-color: #ccc;' class='input_text'><span class='red'>*</span>&nbsp;<input type='button'  class='input_button_2' id='searchDeptBtn' value='请选择' onClick='openDeptDiv(1,this)' />");
	}
	closeCurrentDIV('prodDiv');
	//清空出单机构
	$("#dptCode").val("");
}
//------------------------------------------ 产品  结束----------------------------------------------

//------------------------------------------ 合作伙伴 开始----------------------------------------------
//initTradPartners
function queryPartner(param){
	$.openLoading();
	$.ajax({
		url : "insure/loadChannelInfo",
		type : 'POST',
		async : true,
		data:param,
		dataType:'json',
		success:function(partnerPage){
			$.closeLoading();
			if($.validate(partnerPage))return;

					var radioObj ="<input class='input_fxk' name='partnerradio' type='radio' value=''>";
					var fieldNames = "channelCode@TDH,channelCode,channelName,clientNo@TDH";
					var tableContent = creatTable1(fieldNames,partnerPage,radioObj);
					var tableObj = $("#TradPartnerTable");
					tableObj.find("tbody").remove();
					tableObj.append(tableContent);
					
					var strPage = creatChannelPage2(param.pageIndex,6,partnerPage.maxPage,"16");
					var pageDIV = $("#TradPartnerPageDIV");
					pageDIV[0].innerHTML="";
					pageDIV.append(strPage);
					
					$('#tradPartnerDiv').OpenDiv();
					
					bindradio();
			}
	});
}  



//打开合作伙伴 div 方法
function openThisDiv(divObj,pageIndex,obj){
	if(($.trim($('#prodInstCode').val())).length==0){
		$.message('error',"请先选择产品");
		return;
	}
	$('#channelCode').val('');
	$('#channelName').val('');
	$("#"+obj.id).blur();
	queryTradPartners(pageIndex);
}


//拼接页面查询参数  查询合作伙伴
function mergePartnerParams(pageIndex){
	var size = 8;
	var channelCode = $('#channelCode').val();
	var channelName = $('#channelName').val();
	queryPartner({pageIndex:pageIndex,size:size,channelCode:channelCode,channelName:channelName});
}



//查询 合作伙伴
function queryTradPartners(pageIndex){
	mergePartnerParams(pageIndex);
}


//点击“确定”按钮，选择合作伙伴
function choosePartner(){
	var selectedPartner = $("input[name='partnerradio']:checked");
	if(selectedPartner.length==0){
		$.message("error", "请选择一个合作伙伴");
		return;
	}
	var pno = selectedPartner.parent().parent().children(" td:eq(1)").html();

	var clientNo = selectedPartner.parent().parent().children(" td:eq(4)").html();
	
	
	$('#instCode').val(pno);
	var appSelect = document.getElementById("applicant_no");
	if(clientNo!=""){
		if(appSelect.options.length == 2){
			$("#applicant_no option:eq(0)").remove();
		}
	 	$("#applicant_no").prepend('<option value='+clientNo+'>'+clientNo+'</option>');
	 	$('#applicant_no').attr('value',clientNo);
	}else{
		if(appSelect.options.length == 2){
			$("#applicant_no option:eq(0)").remove();
		}
	}
	closeCurrentDIV('tradPartnerDiv');
	//清空出单机构
	$("#dptCode").val("");
}
//下载方式改变方式
function downloadWayChange(){
	var flag=$('#DownloadWay').val();
	if(flag=='1'){
		$('#fileTypeSpan').show()
	}else{
		$('#fileTypeSpan').hide()
	}
	
}
function clearParams(){
	$('#tradPartnerNo').val('');
	$('#tradPartnerName').val('');
	$('#inspno').val('');
	$('#inspname').val('');
}
//------------------------------------------ 合作伙伴 结束----------------------------------------------
//------------------------------------------ 出单机构 开始----------------------------------------------
//打开机构窗口
function openDeptDiv(pageIndex,obj){
	
	if($.trim($('#instCode').val()).length==0){
		$.message("error", "请先选择合作伙伴代码");
		return;
	}
	
	$('#deptcode').val('');
	$('#deptcnname').val('');
	$("#"+obj.id).blur();
	queryCoreDept(pageIndex);
}

//调用拼接参数的方法，并执行查询
function queryCoreDept(pageIndex){
	var size = 8;
	var code = $('#deptcode').val();
	var name = $('#deptcnname').val();
	var pno = $('#instCode').val();
	queryAllDepts({size:size,pageIndex:pageIndex,deptCode:code,deptCNname:name,channelCode:pno});
}


//查询机构
function queryAllDepts(param){
	$.openLoading();
	$.ajax({
		url : "insure/loadCoreDept",
		type : 'POST',
		async : true,
		data:param,
		dataType:'json',
		success:function(deptPage){
			$.closeLoading();
			if($.validate(deptPage))return;

				var radioObj ="<input class='input_fxk' name='deptradio' type='radio' value=''>";
				var fieldNames = "deptCode,deptCNname";
				var tableContent = creatTable1(fieldNames,deptPage,radioObj);
				var tableObj = $("#deptTable");
				tableObj.find("tbody").remove();
				tableObj.append(tableContent);
				
				var strPage = creatChannelPage3(param.pageIndex,6,deptPage.maxPage,"18");
				var pageDIV = $("#deptPageDIV");
				pageDIV[0].innerHTML="";
				pageDIV.append(strPage);
				
				$("#deptDiv").OpenDiv();
				
				bindradio();
			}
	});
}

//点击“确定” ，选择 出单机构
function chooseDept(){
	var selectedDept= $("input[name='deptradio']:checked");
	if(selectedDept.length==0){
		$.message("error", "请选择一个出单机构");
		return;
	}
	var deptCode = selectedDept.parent().parent().children(" td:eq(1)").html();
	$('#dptCode').val(deptCode);
	closeCurrentDIV('deptDiv');
}

//------------------------------------------ 出单机构 结束----------------------------------------------

//添加 投保方案
function checkAndExcute(flag){
	var planNo = $('#insu_plan_no').val();
	var planName = $.trim($('#insu_plan_name').val());
	if(planName.length==0){
		$.message("error", "请输入投保方案名称");
		$('#insu_plan_name').focus();
		return;
	}
	var prodCode = $.trim($('#prodInstCode').val());
	if(prodCode.length==0){
		$.message("error", "请选择产品编号");
		$('#prodInstCode').focus();
		return;
	}
	var partnerNo = $.trim($('#instCode').val());
	if(partnerNo.length==0){
		$.message("error", "请选择合作伙伴代码");
		$('#instCode').focus();
		return;
	}
	var channle_code = $.trim($('#channelCodeQD').val());
	var channle_type = $.trim($('#channelType').val());
	var newBsns = $.trim($('#newBsnsType').val());
	var categoryCode = $.trim($('#bsnsType').val());
	
	var agentType_val= $("#agentType").val();
	//1、合作伙伴代理3、个人代理4、总对总代理
	var dtpCde = $.trim($('#dptCode').val());
	if(agentType_val!="3"&&agentType_val!="4"){
		if(channle_code.length==0){
			$.message("error", "请选择归属渠道");
			$('#channelCodeQD').focus();
			return;
		}
		if(channle_type.length==0){
			$.message("error", "请选择渠道类型");
			$('#channelType').focus();
			return;
		}
		if(newBsns.length==0){
			$.message("error", "请选择新业务来源");
			$('#newBsnsType').focus();
			return;
		}
		if(categoryCode.length==0){
			$.message("error", "请选择原业务来源");
			$('#bsnsType').focus();
			return;
		}
		if(dtpCde.length==0){
			$.message("error", "请选择出单机构");
			$('#dptCode').focus();
			return;
		}
	}
	var comm_rate = $.trim($('#comm_rate').val());
	if(comm_rate.length==0){
		$.message("error", "请输入手续费比例");
		$('#comm_rate').focus();
		return;
	}else{
	    var reg=/^0(\.\d{0,4})?$/;
	    var resultFlag1 = reg.test(comm_rate);
	    if(!resultFlag1){
	    	$.message("error","手续费比例：只能录入0到1之间的有效数字");
	    	return;
	    }
	}

	
	//1、合作伙伴代理3、个人代理4、总对总代理
	var agent_no ='';
	var protocol_no='';
	var service_code='';
	var emp_no='';
	var team_code='';
	var team_name='';
	if(agentType_val!="3"&&agentType_val!="4"){
		//原业务来源为19002-代理或19003-经纪，则代理人代码和代理协议号必填，其他非必填
		if(categoryCode=="19002"||categoryCode=="19003"){
			agent_no = $.trim($('#agent_no').val());
			if(agent_no.length==0){
				$.message("error", "请输入代理人代码");
				$('#agent_no').focus();
				return;
			}
			protocol_no = $.trim($('#protocol_no').val());
			if(protocol_no.length==0){
				$.message("error", "请输入代理协议号");
				$('#protocol_no').focus();
				return;
			}
		}
		
		service_code = $.trim($('#service_code').val());
		if(service_code.length==0){
			$.message("error", "请输入服务代码");
			$('#service_code').focus();
			return;
		}
		emp_no = $.trim($('#emp_no').val());
		if(emp_no.length==0){
			$.message("error", "请输入业务员代码");
			$('#emp_no').focus();
			return;
		}
		team_code = $.trim($('#team_code').val());
		if(team_code.length==0){
			$.message("error", "请输入团队代码");
			$('#team_code').focus();
			return;
		}
		team_name = $.trim($('#team_name').val());
		if(team_name.length==0){ 
			$.message("error", "请输入团队名称");
			$('#team_name').focus();
			return;
		}
	}
	
	/**
	*   此校验包含新增、编辑
	* 	1、投保人编码为空，a ： 团单——提示不能为空； b ： 个单 且 投保人编码不为空，也不为0 ——赋值为 0
	*/
	var applicant_no = $.trim($('#applicant_no').val());
	if(applicant_no.length==0){ 
		$.message("error", "请选择投保人编码");
		return;
	}
	<%-- 
	if(applicant_no.length==0){
		if(prodAppType==1){
			$.message("error", "投保人编码不能为空，请至合作伙伴配置页面生成投保人编码");
			$('#applicant_no').focus();
			return;
		}else if(prodAppType==0 && applicant_no=="" && partnerNo.length>0){
			$('#applicant_no').val('0');
		}
	}else{
		if(applicant_no=='0'){
				//如果当前产品投保类型是团单：投保人编码不能为空 或 0，提示用户生成编码
			if(prodAppType==1){
				$('#applicant_no').val('');
				$.message("error", "投保人编码不能为空，请至合作伙伴配置页面生成此编码");
				$('#applicant_no').focus();
				return;
			}
		}
	}--%>
	
	var poolInsureCompany="";
	var poolProcotol ="";
	var poolProcotolNo = "";
	var poolIssueFlag = "";
	var poolAgentRate = "";
	var poolRate = "";
	var poolInsureAmount = "";
	var poolRole = "";
	//如果选择的产品共保类型是共保的，才校验这些共保相关的字段
	if(poolType!=0){
		poolInsureCompany = $('#poolInsureCompany').val();
		if(poolInsureCompany==0){
			$.message("error", "请选择保险公司");
			$('#poolInsureCompany').focus();
			return;
		}
		
		poolProcotol = $('#poolProcotol').val();
		if(poolProcotol==0){
			$.message("error", "请选择共保协议");
			$('#poolProcotol').focus();
			return;
		}
		 
		poolProcotolNo = $.trim($('#poolProcotolNo').val());
		if(poolProcotolNo.length==0){
			$.message("error", "请输入共保协议号");
			$('#poolProcotolNo').focus();
			return;
		}
		
		poolIssueFlag = $.trim($('#poolIssueFlag').val());
		if(poolIssueFlag.length==0){
			$.message("error", "请选择出单标志");
			$('#poolIssueFlag').focus();
			return;
		}
		
		poolAgentRate = $.trim($('#poolAgentRate').val());
		if(poolAgentRate.length>0){
		    //小数点. 后面最多保留4位小数，根据数据库 代理、经纪费精度（12,4)
		    var reg = /^([1-9]\d{0,7}|0)(\.\d{1,4})?$/;
		    var resultFlag2= reg.test(poolAgentRate);
		    if(!resultFlag2){
		    	$.message("error","代理、经纪费为长度不超过8位数字且最多保留4位小数的有效数字");
		    	$('#poolAgentRate').focus();
		    	return;
		    }
		}
		
		//共保费率，（4,3） 千分比
		poolRate = $.trim($('#poolRate').val());
		if(poolRate.length>0){
			var regpoolRate = new RegExp("^([1-9][0-9]{0,2}|1000)$");
		    if(!regpoolRate.test(poolRate)){
		    	$.message("error","共保费率请输入1-1000的有效整数");
		    	$('#poolRate').focus();
		    	return;
		    }
		}
	
		poolInsureAmount = $.trim($('#poolInsureAmount').val());
		if(poolInsureAmount.length>0){
		    //小数点. 后面最多保留4位小数，根据数据库 出单费精度（12,4)
		    var reg = /^([1-9]\d{0,7}|0)(\.\d{1,4})?$/;
		    var resultFlag3= reg.test(poolInsureAmount);
		    if(!resultFlag3){
		    	$.message("error","出单费为长度不超过8位数字且最多保留4位小数的有效数字");
		    	return;
		    }
		}
		
		poolRole = $('#poolRole').val();
		if(poolRole==0){
			$.message("error", "请选择共保角色");
			$('#poolRole').focus();
			return;
		}
		
	}
	
	var state = $.trim($('#state').val());
	if('3'==agentType_val||'4'==agentType_val){
		if(flag=="add"){
			if(state==1){//状态为有效
				$.message("error", "销售业务信息为空,保存方案并配置代理信息后才能修改为有效");
				return;
			}
		}
		if(flag=="update"){
			if(state==1){//状态为有效
				if(mapBak.isEmpty()){
					$.message("error", "销售业务信息为空,配置代理信息后才能修改为有效");
					return;
				}	
			}
		}
	}
	
	//是否电子保单
	var isEpolicy_val = $.trim($('#isEpolicy').val());
	var $DownloadWay_val='';
	var fileType='';
	if(isEpolicy_val==''){
		 $.message("error", "请选择是否电子保单");
		return;
	}else if(isEpolicy_val=='Y'){
		 $DownloadWay_val=$.trim($('#DownloadWay').val());
		 if( $DownloadWay_val=='1'){
			 fileType=$('#fileType').val(); 
		 }
	}else{
		$DownloadWay_val='';
	}
	
	//当“是否打印单证”的值为“是”时，单证领用人可输入
	var isPrintCard_val = $.trim($('#isPrintCard').val());
	var cardType_val = $("#cardType").val();
	if(isPrintCard_val==''){
		$.message("error", "请选择是否打印单证");
		return;
	}else if(isPrintCard_val==0){
		if(cardType_val==''){
			$.message("error", "单证类型不能为空");
			$('#cardType').focus();
			return;
		}
		if('1'==agentType_val){
			if($.trim($('#cardApplicant').val()).length==0){
				$.message("error", "单证领用人不能为空");
				$('#cardApplicant').focus();
				return;
			}
		}else if('3'==agentType_val||'4'==agentType_val){
			if(flag=="update"){
				for(i in mapBak.keys()){
					var key = mapBak.keys()[i];
					if(mapBak.get(key).cardapplicant==""){
						$.message("error", "您配置的销售业务信息中存在单证领用人为空的,单证领用人不能为空");
						return;
					}
				}
			}
		}else{
			if($.trim($('#cardApplicant').val()).length==0){
				$.message("error", "单证领用人不能为空");
				$('#cardApplicant').focus();
				return;
			}
		}
	}
	//当“是否发送短信”的值为“是”时，短信模板配置
	var isMessage_val = $.trim($('#is_message').val());
	if(isMessage_val=='Y'){
		if($('#messageReceiver').val()==""){
			$.message("error", "请选择承保短信接收人");
			return;
		}
		if($.trim($('#messageTemplate').val()).length==0){
			$.message("error", "承保短信模板配置不能为空");
			$('#messageTemplate').focus();
			return;
		}
	}

	var messageReceiver_val = $('#messageReceiver').val();
	//是否回执
	var isReceipt_val = $.trim($('#is_receipt').val()); //2015年6月1日11:56:40 wangyan add
	var receiptType_val = $('#receiptType').val();
	if('Y'== isReceipt_val){
		if($('#receiptType').val() == ""){
			$.message("error", "请选择回执类型");
			return;
		}
	}else if('N'== isReceipt_val){
		receiptType_val="";
	}
	
	 //是否发送电子发票
	var $isEpolicyInvoice=$.trim($('#isEpolicyInvoice').val());
	if( $isEpolicyInvoice==''){
		$.message("error","请选择是否发送电子发票");
		return ;
	}
	//是否开通支付平台
	var $isDredgePay=$.trim($('#isDredgePay').val());
	//是否见费出单
	var $isSeeMoney = $.trim($('#isSeeMoney').val());
	if($isDredgePay==''){
		$.message('error',"请选择是否开通支付平台");
		return;
	}
	if($isSeeMoney==2){
		$isDredgePay="";
	}
	//是否发送邮件
	var $isEpolicyMali=$.trim($('#isEpolicyMali').val());
	//邮件模板
	var $MailTemplate=$.trim($('#MailTemplate').val());
	//转码，可能会传入html的数据
	if($MailTemplate!=null){
		$MailTemplate=encodeURI($MailTemplate);
	}
	//获取附加数组
	var selectAccessorys=$('input[name=SendAccessoryBox]:checked');
	//定义一个转换后的字符串
	var selectAccessorylistStr='';
	//判断数组长度
	if(selectAccessorys.length!=0){
		//循环添加
		selectAccessorys.each(function(i){
			var object=new Object();
			object.id=$(this).val();
			map.put(object.id,object);
		});
	}
	//判断map是否为空
	if(!map.isEmpty()){
		//定义list
		var selectAccessorylist =new  Array();
		//循环k值
		for(i in map.keys()){
			//得到key
			var key=map.keys()[i];
			//得到值
			selectAccessorylist.push(map.get(key));
		}
		//转换成字符串
		selectAccessorylistStr=JSON.stringify(selectAccessorylist);
	}
	//是否发送邮件
	if($isEpolicyMali=='1'){
		if($.trim($('#MailTemplate').val()).length==0){
			$.message('error',"请输入邮件模板配置");
			$('#MailTemplate').focus();
			return ;
		}
	}else{
		$MailTemplate="";
		selectAccessorylistStr="";
	}
	
	
	var $isEpolicyMali=$.trim($('#isEpolicyMali').val());
	var special_arran = $.trim($('#special_arran').val());
	/* ---- */
	var $isReceiverEpolicy=$.trim($('#isReceiverEpolicy').val());
	var $isEpolicyInvoice=$.trim($('#isEpolicyInvoice').val());
	/* ----- */
	var isPrintCard= $.trim($('#isPrintCard').val());
    var cardApplicant =$.trim($('#cardApplicant').val());
    var messageTemplate =$.trim($('#messageTemplate').val());
    var messageTemplate_val =$('#smsTemplate').val();
    //温馨提示
    var reminder =$.trim($('#reminder').val());
	//注销短信
	var isCancelMessage=$('#isCancelMessage').val();
	var cancelReceiver=$('#cancelReceiver').val();
	var cancelTemplate= $('#isCancelTemplate').val();
	var cancelTemplate_val=$.trim($('#cancelTemplate').val());
	if(cancelTemplate_val!=null){
		cancelTemplate_val=encodeURI(cancelTemplate_val);
	}
	if(isCancelMessage=="Y"){
		if(cancelReceiver.length==0){
			$.message("error", "请选择注销短信接收人");
			return;
		}
		if(cancelTemplate_val.length==0){
			$.message("error", "注销短信模板配置不能为空");
			return;
		}
	}else{
		cancelReceiver='';
		cancelTemplate='';
	}
	if(flag=="add"){
		excuteAdd({fileType:fileType,isCancelMessage:isCancelMessage,cancelReceiver:cancelReceiver,cancelTemplate:cancelTemplate,insuPlanName:planName,tradProdCode:prodCode,partnerNo:partnerNo,dptCde:dtpCde,
			newBsnsType:newBsns,channleCode:channle_code,channleType:channle_type,categoryCode:categoryCode,agentNo:agent_no,protocolNo:protocol_no,
			commRate:comm_rate,serviceCode:service_code,empNo:emp_no,teamCode:team_code,teamName:team_name,applicantNo:applicant_no,isMessage:isMessage_val,state:state,
			specialArran:special_arran,isSeeMoney:$isSeeMoney,poolInsureCompany:poolInsureCompany,poolProcotol:poolProcotol,
			poolProcotolNo:poolProcotolNo,poolIssueFlag:poolIssueFlag,poolAgentRate:poolAgentRate,poolRate:poolRate,poolInsureAmount:poolInsureAmount,poolRole:poolRole,
			isPrintCard:isPrintCard,cardApplicant:cardApplicant,isEpolicy:isEpolicy_val,messageTemplate:messageTemplate_val,isReceipt:isReceipt_val,
			messageReceiver:messageReceiver_val,cardType:cardType_val,reminder:reminder,receiptType:receiptType_val,EpolicyInvoice:$isEpolicyInvoice,DredgePay:$isDredgePay,EpolicyMali:$isEpolicyMali,MailTemplate:$MailTemplate,selectAccessorylistStr:selectAccessorylistStr,DownloadWay:$DownloadWay_val});
	}
	if(flag=="update"){
		excuteUpdate({fileType:fileType,isCancelMessage:isCancelMessage,cancelReceiver:cancelReceiver,cancelTemplate:cancelTemplate,insuPlanNo:planNo,insuPlanName:planName,tradProdCode:prodCode,partnerNo:partnerNo,dptCde:dtpCde,
			newBsnsType:newBsns,channleCode:channle_code,channleType:channle_type,categoryCode:categoryCode,agentNo:agent_no,protocolNo:protocol_no,
			commRate:comm_rate,serviceCode:service_code,empNo:emp_no,teamCode:team_code,teamName:team_name,applicantNo:applicant_no,isMessage:isMessage_val,state:state,
			specialArran:special_arran,isSeeMoney:$isSeeMoney,poolInsureCompany:poolInsureCompany,poolProcotol:poolProcotol,
			poolProcotolNo:poolProcotolNo,poolIssueFlag:poolIssueFlag,poolAgentRate:poolAgentRate,poolRate:poolRate,poolInsureAmount:poolInsureAmount,poolRole:poolRole,
			isPrintCard:isPrintCard,cardApplicant:cardApplicant,isEpolicy:isEpolicy_val,messageTemplate:messageTemplate_val,isReceipt:isReceipt_val,
			messageReceiver:messageReceiver_val,cardType:cardType_val,reminder:reminder,receiptType:receiptType_val,EpolicyInvoice:$isEpolicyInvoice,DredgePay:$isDredgePay,EpolicyMali:$isEpolicyMali,MailTemplate:$MailTemplate,selectAccessorylistStr:selectAccessorylistStr,DownloadWay:$DownloadWay_val});
	}
}

//执行修改
function excuteUpdate(param){
	$.openLoading();
	$.ajax({
		url : "insure/updateInsuPlanInfo",
		type : 'POST',
		async : true,
		data:param,
		dataType:'json',
		success:function(data){
			$.closeLoading();
			if($.validate(data))return;
			back('edit');
		}
	});
}

//执行添加
function excuteAdd(param){
	$.openLoading();
	$.ajax({
		url : "insure/addTradInsuPlan",
		type : 'POST',
		async : true,
		data:param,
		dataType:'json',
		success:function(data){
			$.closeLoading();
			if("success"==data.result&&""!=data.message){
				if(data.data.AgentType=="1"){
					$.message("success", data.message);
					back('add');
				}else if(data.data.AgentType=="3"){
					$.message("success", data.message);
					//保存完更新方案号
					$("#insu_plan_no").val(data.data.InsuPlanNo);
					window.location.href='<%=path%>/insure/edit?insuPlanNo='+data.data.InsuPlanNo;
				}else if(data.data.AgentType=="4"){
					$.message("success", data.message);
					//保存完更新方案号
					$("#insu_plan_no").val(data.data.InsuPlanNo);
					window.location.href='<%=path%>/insure/edit?insuPlanNo='+data.data.InsuPlanNo;
				}
	    	}
			if("fail"==data.result){
	    		$.message("error", "系统错误,请联系管理员");
	    	}
			if("error"==data.result&&""!=data.message){
	    		$.message("error", data.message);
	    	}
		}
	});
}


//返回
function back(obj){
	if(obj=='edit'){
		this.location.href = "<%=path%>/insure/success?flag=edittrue";
	}
	if(obj=='add'){
		this.location.href = "<%=path%>/insure/success?flag=addtrue";
	}
}

function clearNoNum(event,obj){ 
    //响应鼠标事件，允许左右方向键移动 
    event = window.event||event; 
    if(event.keyCode == 37 | event.keyCode == 39){ 
        return; 
    } 
    //先把非数字的都替换掉，除了数字和. 
    obj.value = obj.value.replace(/[^\d.]/g,""); 
    //必须保证第一个为数字而不是. 
    obj.value = obj.value.replace(/^\./g,""); 
    //保证只有出现一个.而没有多个. 
    obj.value = obj.value.replace(/\.{2,}/g,"."); 
    //保证.只出现一次，而不能出现两次以上 
    obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$","."); 
} 
function checkNum(obj){ 
    //为了去除最后一个. 
    obj.value = obj.value.replace(/\.$/g,""); 
}

//返回按钮
function goBack(){
	this.location.href = "<%=path%>/insure/list";
}

//当“是否打印单证”的值为“是”时，单证领用人可输入
function checkPrintCard(){
	var type = $('#isPrintCard').val();
	if(type=='0'){
		$('#cardApplicant').attr("readonly",false);
		$('#cardApplicant').css("background-color","white");
		$('#cardType').attr("readonly",false);
		$('#cardType').css("background-color","white");
	}else{
		$('#cardApplicant').val('');
		$('#cardApplicant').attr("readonly",true);
		$('#cardApplicant').css("background-color","#ccc");
		$('#cardType').val('');
		$('#cardType').attr("readonly",true);
		$('#cardType').css("background-color","#ccc");
	}
}
function chooseReceiptType(){
	var value = $('#is_receipt').val();
	if('Y' == value){
		$('#isOrNotDisplayReceiptTypeDiv').show();
	}else if('N' == value){
		$('#isOrNotDisplayReceiptTypeDiv').hide();
		$('#receiptType').val('01');
	}
}
//当“是否发送短信”的值为“是”时，短信模板配置可输入
function checkIsMessage(){
	var value = $('#is_message').val();
	if(value=='Y'){
		$('#messageTemplateTr').show();
		$('#messageTemplate').css("background-color","white");
		$('#messageReceiverDiv').show();
		$('#smsTemplateDiv').show();
		$('#messageTemplate').attr("disabled",true).css("background-color","rgb(204, 204, 204)");
	}else{
		$('#messageTemplateTr').hide();
		$('#messageTemplate').val('');
		$('#messageReceiverDiv').hide();
		$('#smsTemplateDiv').hide();
		$('#smsTemplate').val('');
	}
}

//承保短信模板
function changeIsMessageTemplate(){
	var value = $('#smsTemplate').val();
	if(value ==null || "" == value || "0" == value){
		$('#messageTemplate').val("");
		return false;
	}
	 $.ajax({
		 	url : "<%=path%>/insure/loadTemplate",
			type : 'POST',
			async : true,
			dataType:'json',
			data:{smsTemplateCode:value},
			success : function(obj) {
				var smsTemplate = obj;
				$('#messageTemplate').val(obj.smsTemplateText);
			}
	});
}

//注销短信模板
function changeIsCacelTemplate(){
	var value = $('#isCancelTemplate').val();
	if(value ==null || "" == value || "0" == value){
		$('#cancelTemplate').val("");
		return false;
	}
	 $.ajax({
		 	url : "<%=path%>/insure/loadTemplate",
			type : 'POST',
			async : true,
			dataType:'json',
			data:{smsTemplateCode:value},
			success : function(obj) {
				var smsTemplate = obj;
				$('#cancelTemplate').val(obj.smsTemplateText);
			}
	});
}
$(document).ready(function(){
	//归属渠道
	$("#channelCodeQD").change(function(){
		var parentCode = $("#channelCodeQD").val();
		subDropDownList("channel_type",parentCode,"channelType");
		subDropDownList("new_business_source","","newBsnsType");
	});
	//渠道类型
	$("#channelType").change(function(){
		var parentCode = $("#channelType").val();
		subDropDownList("new_business_source",parentCode,"newBsnsType");
		if(parentCode==''){
			$("#bsnsType").val('');
		}
	});
	//新业务来源   style=" background-color: #ccc;"
	$("#newBsnsType").change(function(){
		var parentCode = $("#channelType").val();
		var newBsnsCode = $("#newBsnsType").val();
		var myselect=document.getElementById("newBsnsType");
		var index=myselect.selectedIndex;
		var index2=myselect.options[index].text;
		if(index2.indexOf("直销")>=0){
			$("#agent_no").val("");
			$("#agent_no").attr("disabled",true);
			$("#protocol_no").val("");
			$("#protocol_no").attr("disabled",true);
			document.getElementById("agent_no").style.cssText="background-color: #ccc;";
			document.getElementById("protocol_no").style.cssText="background-color: #ccc;";
		}else{
			$("#agent_no").attr("disabled",false);
			$("#protocol_no").attr("disabled",false);
			document.getElementById("agent_no").style.cssText="none;";
			document.getElementById("protocol_no").style.cssText="none;";
		}
		chooseBsnsType(parentCode,newBsnsCode);

	});
	//旧业务来源
	$("#bsnsType").change(function(){
		var newBsnsCode = $("#newBsnsType").val();
		var bsnsTypeCode = $("#bsnsType").val();
		//原业务来源为19002-代理或19003-经纪，则代理人代码和代理协议号必填，其他非必填
		if(bsnsTypeCode!="19002"&&bsnsTypeCode!="19003"){
			$("#agent_no ~ span").remove(".red");
			$("#protocol_no ~ span").remove(".red");
		}else{
			if($("#agent_no ~ span").length==0){
				$("#agent_no").parent().append("<span class='red'>*</span>");
			}
			if($("#protocol_no ~ span").length==0){
				$("#protocol_no").parent().append("<span class='red'>*</span>");
			}
		}
	});
});
//下拉框处理
function subDropDownList(codeType,element1,element2,element3){
	$.ajax({
		url : "<%=path%>/insure/loadSubDropList",
		type : 'POST',
		async : false,
		data:{codeType:codeType,parentCode:element1},
		dataType:'json',
		success:function(appList){
			if($.validate(appList))  return;
			var appSelect = document.getElementById(element2);
			appSelect.options.length = 0;
			if (appList != null) {
				for (var i = 0; i < appList.length; i++) {
					var option = new Option();
					option.text = appList[i].codeName;
					option.value = appList[i].code;
					appSelect.add(option);
				}
			}
       	}
	});
}
//选择旧业务来源
function chooseBsnsType(parentCode,newBsnsCode){
	$.ajax({
		url : "<%=path%>/insure/chooseBsnsType",
		type : 'POST',
		async : false,
		data:{parentCode:parentCode,newBsnsCode:newBsnsCode},
		dataType:'json',
		success:function(data){
				if($.validate(data))  return;
				if (data != null) {
					$("#bsnsType").val(data.otherCode);
					//原业务来源为19002-代理或19003-经纪，则代理人代码和代理协议号必填，其他非必填
					if(data.otherCode=="19002"||data.otherCode=="19003"){
						if($("#agent_no ~ span").length==0){
							$("#agent_no").parent().append("<span class='red'>*</span>");
						}
						if($("#protocol_no ~ span").length==0){
							$("#protocol_no").parent().append("<span class='red'>*</span>");
						}
					}else{
						$("#agent_no ~ span").remove(".red");
						$("#protocol_no ~ span").remove(".red");
					}
				}
       	}
	});
}

//------------------------------------------配置代理信息开始--------------------------------------------
//统一 关闭  窗口
function closeAgentTypeDiv(obj){
	var selectedAgentType = $("input[name^=agentType]:checked");
	if(selectedAgentType.length!=0){
		selectedAgentType.each(function(i){
			$(this).prop("checked",false);
		});
	}
	map.clear();
	for(i in mapBak.keys()){
        var key = mapBak.keys()[i];
        map.put(key,mapBak.get(key));
    }

	$("#"+obj).CloseDiv();	
}
//打开产品窗口
function openAgentType3Div(pageIndex,obj){
	var planno = $("#insu_plan_no").val();
	if(planno==""){
		$.message("error", "请先保存投保方案");
		return;
	}
	$('#confStatus').val("ALL");
	$('#agentCode').val('');
	$('#agentName').val('');

	$("#"+obj.id).blur();
	queryConfProxyInfo3(pageIndex);
}
//调用拼接参数的方法，并执行查询
function queryConfProxyInfo3(pageIndex){
	var size = 10;
	var agentType = '3';
	if($.trim($('#instCode').val()).length==0){
		$.message("error", "请先选择合作伙伴代码");
		return;
	}
	var selectedAgentType3 = $("input[name='agentType3checkbox']:checked");
	if(selectedAgentType3.length!=0){
		var flag= false;
		selectedAgentType3.each(function(i){
			var obj=$(this).parent().parent().find("input[name='value']");
			var value= obj.val();
			if(value!=""){
				var reg=/^0(\.\d{0,4})?$/;
		    	var resultFlag1 = reg.test(value);
		        if(!resultFlag1){
		        	flag = true;
		        	$.message("error","手续费比例：只能录入0到1之间的有效数字");
		        	window.setTimeout(function(){ obj.focus(); }, 0);
		        	return false; 
		        }
		    }
		});
		if(flag){
			return;
		}
	}
	if(selectedAgentType3.length!=0){
		selectedAgentType3.each(function(i){
			var obj = new Object();
			obj.id= $(this).parent().parent().children(" td:eq(1)").html();
			obj.cardapplicant= $(this).parent().parent().children(" td:eq(7)").html();
			obj.value= $(this).parent().parent().find("input[name='value']").val();
			map.put(obj.id,obj);
		});
	}
	var code = $('#instCode').val();
	var confStatus_val = $('#confStatus').val();
	var agentName_val=$('#agentName').val();
	var agentCode_val=$('#agentCode').val();
	var insuPlanNo =$("#hidepno").val();
	loadConfigureInfo3({size:size,pageIndex:pageIndex,channelCode:code,agentType:agentType,confStatus:confStatus_val,userName:agentName_val,userCode:agentCode_val,insuPlanNo:insuPlanNo});
}
//配置代理信息
function loadConfigureInfo3(param){
	$.openLoading();
	$.ajax({
		url : "insure/loadConfProxyInfo",
		type : 'POST',
		async : true,
		data:param,
		dataType:'json',
		success:function(partnerPage){
			$.closeLoading();
			if($.validate(partnerPage))return;

				var checkboxObj ="<input name='agentType3checkbox' type='checkbox'>";
				var fieldNames = "ID@TDH,USERCODE,USERNAME,DPTCDE,SERVICECODE,EMPNO,CARDAPPLICANT,TEAMCODE,CHANNLECODE@TDH,CHANNLECODEDES,CHANNLETYPE@TDH,CHANNLETYPEDES,NEWBSNSTYPE@TDH,NEWBSNSTYPEDES,CATEGORYCODE@TDH,CATEGORYCODEDES,AGENTNO,PROTOCOLNO";
				var inputObj ="<input style='width:100%' name='value' onchange='valueChange(this)' type='text' value=''>";
				var tableContent = creatTable1(fieldNames,partnerPage,checkboxObj,inputObj);
				var tableObj = $("#agentTypeDiv3Table");
				tableObj.find("tbody").remove();
				tableObj.append(tableContent);
				
				var strPage = creatChannelPage4(param.pageIndex,6,partnerPage.maxPage,"30");
				var pageDIV = $("#agentTypeDiv3Page");
				pageDIV[0].innerHTML="";
				pageDIV.append(strPage);
				
				$("#agentTypeDiv3Table").find("tr").each(function(){
					var id = $(this).children(" td:eq(1)").html();
					if(map.containsKey(id)){
						$(this).addClass("table_highlighter");
						$(this).children("td:eq(0)").find("input[name='agentType3checkbox']").prop("checked",true);
						$(this).find("input[name='value']").val(map.get(id).value);
					}
				});
				
				$('#agentTypeDiv3').OpenDiv();
				
				bindradio();
			}
	});
}
function valueChange(obj){
	var reg=/^0(\.\d{0,4})?$/;
    if(obj.value!=""){
    	var resultFlag1 = reg.test(obj.value);
        if(!resultFlag1){
        	$.message("error","手续费比例：只能录入0到1之间的有效数字");
        	window.setTimeout(function(){ obj.focus(); }, 0);
        	return false; 
        }
    }
}

function saveChooseAgentType3(){
	var selectedAgentType3 = $("input[name='agentType3checkbox']:checked");
	if(selectedAgentType3.length!=0){
		var flag= false;
		selectedAgentType3.each(function(i){
			var obj=$(this).parent().parent().find("input[name='value']");
			var value= obj.val();
			if(value!=""){
				var reg=/^0(\.\d{0,4})?$/;
		    	var resultFlag1 = reg.test(value);
		        if(!resultFlag1){
		        	$.message("error","手续费比例：只能录入0到1之间的有效数字");
		        	flag = true;
		        	window.setTimeout(function(){ obj.focus(); }, 0);
		        	return false; 
		        }
		    }
		});
		if(flag){
			return;
		}
	}
	if(selectedAgentType3.length!=0){
		selectedAgentType3.each(function(i){
			var obj = new Object();
			obj.id= $(this).parent().parent().children(" td:eq(1)").html();
			obj.cardapplicant= $(this).parent().parent().children(" td:eq(7)").html();
			obj.value= $(this).parent().parent().find("input[name='value']").val();
			map.put(obj.id,obj);
		});
	}
	var planno = $("#insu_plan_no").val();
	
	if(map.isEmpty()){
		$.message("error", "请选择销售业务信息");
		return;
	}else{
		var isPrintCard_val = $.trim($('#isPrintCard').val());
		agentTypeList = new Array();
		for(i in map.keys()){
	        var key = map.keys()[i];
	        if(isPrintCard_val==0){
	        	if(map.get(key).cardapplicant==""){
		        	$.message("error", "该方案为打印单证,您选择的销售业务信息中存在单证领用人为空的,请调整后添加");
		    		return;
		        }
	        }
	        agentTypeList.push(map.get(key));
	    }
		mapBak.clear();
		for(i in map.keys()){
	        var key = map.keys()[i];
	        mapBak.put(key,map.get(key));
	    }
		agentTypeListStr=JSON.stringify(agentTypeList);
	}
	
	updateProxyInfo({insuPlanNo:planno,agentTypeList:agentTypeListStr});
	
	closeCurrentDIV('agentTypeDiv3');
}
//执行更新
function updateProxyInfo(param){
	$.openLoading();
	$.ajax({
		url : "insure/updateProxyInfo",
		type : 'POST',
		async : true,
		data:param,
		dataType:'json',
		success:function(data){
			$.closeLoading();
			if($.validate(data))return;
			var planno = $("#insu_plan_no").val();
			var agentType_val= $("#agentType").val();
			if(agentType_val=="3"){
				queryConfProxyInfoEdit3(1);
			}
			if(agentType_val=="4"){
				queryConfProxyInfoEdit4(1);
			}
		}
	});
}

function openAgentType4Div(pageIndex,obj){
	var planno = $("#insu_plan_no").val();
	if(planno==""){
		$.message("error", "请先保存投保方案");
		return;
	}
	$('#confStatus4').val("ALL");
	$('#branch').val('');
	$('#branchName').val('');

	$("#"+obj.id).blur();
	queryConfProxyInfo4(pageIndex);
}
function queryConfProxyInfo4(pageIndex){
	var size = 10;
	var agentType = '4';
	if($.trim($('#instCode').val()).length==0){
		$.message("error", "请先选择合作伙伴代码");
		return;
	}
	var selectedAgentType4 = $("input[name='agentType4checkbox']:checked");
	if(selectedAgentType4.length!=0){
		var flag= false;
		selectedAgentType4.each(function(i){
			var obj=$(this).parent().parent().find("input[name='value']");
			var value= obj.val();
			if(value!=""){
				var reg=/^0(\.\d{0,4})?$/;
		    	var resultFlag1 = reg.test(value);
		        if(!resultFlag1){
		        	$.message("error","手续费比例：只能录入0到1之间的有效数字");
		        	flag = true;
		        	window.setTimeout(function(){ obj.focus(); }, 0);
		        	return false; 
		        }
		    }
		});
		if(flag){
			return;
		}
	}
	if(selectedAgentType4.length!=0){
		selectedAgentType4.each(function(i){
			var obj = new Object();
			obj.id= $(this).parent().parent().children(" td:eq(1)").html();
			  var columnes=$("#agentTypeDiv4Table").find("th").length;
			    if(columnes==16){
					obj.cardapplicant= $(this).parent().parent().children("td:eq(10)").html();
			    }else if(columnes==18){
					obj.cardapplicant= $(this).parent().parent().children("td:eq(12)").html();
			    }
			obj.value= $(this).parent().parent().find("input[name='value']").val();
			map.put(obj.id,obj);
		});
	}
	var code = $('#instCode').val();
	var confStatus_val = $('#confStatus4').val();
	var branch_val=$('#branch').val();
	var branchName_val=$('#branchName').val();
	var insuPlanNo =$("#hidepno").val();
	loadConfigureInfo4({size:size,pageIndex:pageIndex,channelCode:code,agentType:agentType,confStatus:confStatus_val,insuPlanNo:insuPlanNo,branch:branch_val,branchName:branchName_val});
}
function loadConfigureInfo4(param){
	$.openLoading();
	$.ajax({
		url : "insure/loadConfProxyInfo",
		type : 'POST',
		async : true,
		data:param,
		dataType:'json',
		success:function(partnerPage){
			$.closeLoading();
			var flang = false; 
			var fieldNames ;
			if($.validate(partnerPage))return;
				$.each(partnerPage.data, function(k, v){
				 if(v.TRANSTYPE=='1'){
					 flang=true;
				 }
				 return false; 
				});
				var checkboxObj ="<input name='agentType4checkbox' type='checkbox'>";
				var columnes = $("#agentTypeDiv4Table").find("th").length;
				if(flang){
					 fieldNames = "ID@TDH,CHANNELCODE@TDH,SUBCHANNELCODE@TDH,BRANCH,BRANCHNAME,USERCODE,USERNAME,ZONE,DPTCDE,SERVICECODE,EMPNO,CARDAPPLICANT,TEAMCODE,CHANNLECODE@TDH,CHANNLECODEDES,CHANNLETYPE@TDH,CHANNLETYPEDES,NEWBSNSTYPE@TDH,NEWBSNSTYPEDES,CATEGORYCODE@TDH,CATEGORYCODEDES,AGENTNO,PROTOCOLNO,COMMRATE";
				}else{
					 //先删除表头
					 if(columnes == 18){
						$("#agentTypeDiv4Table tr th:eq(3)").remove();
						$("#agentTypeDiv4Table tr th:eq(3)").remove();
					 }
					 fieldNames = "ID@TDH,CHANNELCODE@TDH,SUBCHANNELCODE@TDH,BRANCH,BRANCHNAME,ZONE,DPTCDE,SERVICECODE,EMPNO,CARDAPPLICANT,TEAMCODE,CHANNLECODE@TDH,CHANNLECODEDES,CHANNLETYPE@TDH,CHANNLETYPEDES,NEWBSNSTYPE@TDH,NEWBSNSTYPEDES,CATEGORYCODE@TDH,CATEGORYCODEDES,AGENTNO,PROTOCOLNO,COMMRATE";
				}
				
				var inputObj ="<input style='width:100%' name='value' onchange='valueChange(this)' type='text' value=''>";
				var tableContent = creatTable1(fieldNames,partnerPage,checkboxObj,inputObj);
				var tableObj = $("#agentTypeDiv4Table");
				tableObj.find("tbody").remove();
				tableObj.append(tableContent);
				
				var strPage = creatChannelPage4(param.pageIndex,6,partnerPage.maxPage,"32");
				var pageDIV = $("#agentTypeDiv4Page");
				pageDIV[0].innerHTML="";
				pageDIV.append(strPage);
				
				$("#agentTypeDiv4Table").find("tr").each(function(){
					var id = $(this).children(" td:eq(1)").html();
					if(map.containsKey(id)){
						$(this).addClass("table_highlighter");
						$(this).children("td:eq(0)").find("input[name='agentType4checkbox']").prop("checked",true);
						$(this).find("input[name='value']").val(map.get(id).value);
					}
				});
				
				$('#agentTypeDiv4').OpenDiv();
				
				bindradio();
			}
	});
}
function saveChooseAgentType4(){
	var selectedAgentType4 = $("input[name='agentType4checkbox']:checked");
	if(selectedAgentType4.length!=0){
		var flag= false;
		selectedAgentType4.each(function(i){
			var obj=$(this).parent().parent().find("input[name='value']");
			var value= obj.val();
			if(value!=""){
				var reg=/^0(\.\d{0,4})?$/;
		    	var resultFlag1 = reg.test(value);
		        if(!resultFlag1){
		        	$.message("error","手续费比例：只能录入0到1之间的有效数字");
		        	flag = true;
		        	window.setTimeout(function(){ obj.focus(); }, 0);
		        	return false; 
		        }
		    }
		});
		if(flag){
			return;
		}
	}
	if(selectedAgentType4.length!=0){
		selectedAgentType4.each(function(i){
			var obj = new Object();
			 
			obj.id= $(this).parent().parent().children(" td:eq(1)").html();
			  var columnes=$("#agentTypeDiv4Table").find("th").length;
				if(columnes==16){
					obj.cardapplicant= $(this).parent().parent().children(" td:eq(10)").html();
				}else if(columnes==18){
					obj.cardapplicant = $(this).parent().parent().children(" td:eq(12)").html();
				}
			obj.value= $(this).parent().parent().find("input[name='value']").val();
			map.put(obj.id,obj);
		});
	}
	var planno = $("#insu_plan_no").val();
	
	if(map.isEmpty()){
		$.message("error", "请选择销售业务信息");
		return;
	}else{
		var isPrintCard_val = $.trim($('#isPrintCard').val());
		agentTypeList = new Array();
		for(i in map.keys()){
	        var key = map.keys()[i];
	        if(isPrintCard_val==0){
	        	if(map.get(key).cardapplicant==""){
		        	$.message("error", "该方案为打印单证,您选择的销售业务信息中存在单证领用人为空的,请调整后添加");
		    		return;
		        }
	        }
	        agentTypeList.push(map.get(key));
	    }
		mapBak.clear();
		for(i in map.keys()){
	        var key = map.keys()[i];
	        mapBak.put(key,map.get(key));
	    }
		agentTypeListStr=JSON.stringify(agentTypeList);
	}
	
	updateProxyInfo({insuPlanNo:planno,agentTypeList:agentTypeListStr});
	
	closeCurrentDIV('agentTypeDiv4');
}
function queryConfProxyInfoEdit3(pageIndex){
	var size = 5;
	var insplanno = $('#insu_plan_no').val();
	var agentType ="3";
	loadConfigureInfoEdit3({size:size,pageIndex:pageIndex,insuPlanNo:insplanno,agentType:agentType});
}
//配置代理信息
function loadConfigureInfoEdit3(param){
	$.ajax({
		url : "insure/loadConfProxyInfoEdit",
		type : 'POST',
		async : true,
		data:param,
		dataType:'json',
		success:function(partnerPage){
			$.closeLoading();
			if($.validate(partnerPage))return;

				var fieldNames = "USERCODE,USERNAME,DPTCDE,SERVICECODE,EMPNO,CARDAPPLICANT,TEAMCODE,CHANNLECODE@TDH,CHANNLECODEDES,CHANNLETYPE@TDH,CHANNLETYPEDES,NEWBSNSTYPE@TDH,NEWBSNSTYPEDES,CATEGORYCODE@TDH,CATEGORYCODEDES,AGENTNO,PROTOCOLNO,COMMRATE";
				var tableContent = creatTable1(fieldNames,partnerPage);
				var tableObj = $("#agentType3Table");
				tableObj.find("tbody").remove();
				tableObj.append(tableContent);
				
				var strPage = creatChannelPage3(param.pageIndex,6,partnerPage.maxPage,"31");
				var pageDIV = $("#agentType3TablePageDIV");
				pageDIV[0].innerHTML="";
				pageDIV.append(strPage);
				
			}
	});
}
function queryConfProxyInfoEdit4(pageIndex){
	var size = 5;
	var insplanno = $('#hidepno').val();
	var agentType ="4";
	loadConfigureInfoEdit4({size:size,pageIndex:pageIndex,insuPlanNo:insplanno,agentType:agentType});
}
function loadConfigureInfoEdit4(param){
	$.ajax({
		url : "insure/loadConfProxyInfoEdit",
		type : 'POST',
		async : true,
		data:param,
		dataType:'json',
		success:function(partnerPage){
			$.closeLoading();
			var flang=false;
			var fieldNames ;
			if($.validate(partnerPage))return;
			$.each(partnerPage.data, function(k, v){
			 if(v.TRANSTYPE=='1'){
				 flang=true;
			 }
			 return false; 
			});
			var columnes = $("#agentType4Table").find("th").length;
			if(flang){
				fieldNames= "BRANCH,BRANCHNAME,USERCODE,USERNAME,ZONE,DPTCDE,SERVICECODE,EMPNO,CARDAPPLICANT,TEAMCODE,CHANNLECODE@TDH,CHANNLECODEDES,CHANNLETYPE@TDH,CHANNLETYPEDES,NEWBSNSTYPE@TDH,NEWBSNSTYPEDES,CATEGORYCODE@TDH,CATEGORYCODEDES,AGENTNO,PROTOCOLNO,COMMRATE";
				 $("#agentType4Table tr:eq(1) td:eq(0)").attr("colspan",17).siblings().remove(); 
			}else{
			    //先删除表头
			    if(columnes ==17){
					$("#agentType4Table tr th:eq(2)").remove();
					$("#agentType4Table tr th:eq(2)").remove();
			    }
				 fieldNames = "BRANCH,BRANCHNAME,ZONE,DPTCDE,SERVICECODE,EMPNO,CARDAPPLICANT,TEAMCODE,CHANNLECODE@TDH,CHANNLECODEDES,CHANNLETYPE@TDH,CHANNLETYPEDES,NEWBSNSTYPE@TDH,NEWBSNSTYPEDES,CATEGORYCODE@TDH,CATEGORYCODEDES,AGENTNO,PROTOCOLNO,COMMRATE";
				 $("#agentType4Table tr:eq(1) td:eq(0)").attr("colspan",15).siblings().remove(); 
			}	
			
				var tableContent = creatTable1(fieldNames,partnerPage);
				var tableObj = $("#agentType4Table");
				tableObj.find("tbody").remove();
				tableObj.append(tableContent);
				
				var strPage = creatChannelPage3(param.pageIndex,6,partnerPage.maxPage,"34");
				var pageDIV = $("#agentType4TablePageDIV");
			 
				pageDIV[0].innerHTML="";
				pageDIV.append(strPage);
				
			}
	});
}
	function CheckedSendMail(){
		var ChecdedMail=$("#isEpolicyMali").val();
		if(ChecdedMail==1){
			$("#MailTemplateTr").show();
			$('#MailTemplate').html("");
			$("#sendAccessory").show();
			$("#sendAccessoryTd").show();
			$('#SendAccessoryBox').show();
		}else{
			$("#MailTemplateTr").hide();
			$("#sendAccessory").hide();
			$("#sendAccessoryTd").hide();
		}
	}
	function IsEpolicyChange(){
		var $IsEpolicy =$.trim($('#isEpolicy').val());
		var $Download_right=$('#Download_right');
		if($IsEpolicy=='Y'){
			$Download_right.show();
		}else{
			$Download_right.hide();
		}
	}
	
	function SeeMoneyChange(){
		var isSeeMoney =$('#isSeeMoney').val();
		if(isSeeMoney==2){
			$('#isDredgePay').val(1);
			$('#isDredgePay').attr("disabled",true);
			$("#isDredgePay").css({"background-color": "#ccc"});
		}else{
			$("#isDredgePay").attr("disabled",false);
			$("#isDredgePay").css({"background-color": ""});
		}
	}


//------------------------------------------配置代理信息结束-------------------------------------------
</script>
</head>
<body>
<c:if test="${not empty param.insuPlanNo }">
<input type="hidden" value="${param.insuPlanNo }" id="hidepno">
	      <div class="current">
           <table class="current_table_1">
              <tbody>
                <tr class="f2">
                  <td>
                    <img src="./images/current_1.jpg">
                  </td>
                  <td class="current_table_1_td">
                    <img src="images/current_1.png">&nbsp;您现在的位置：&nbsp;
                      <span style=" color:#136bab; ">产品管理
                         <span style="padding:0 5px; font-weight:bold; line-height:28px;">&gt;</span>方案配置
                         <span style="padding:0 5px; font-weight:bold; line-height:28px;">&gt;</span>投保方案编辑
                      </span>
                  </td>
                  <td><img src="./images/current_3.jpg"></td>
              </tr>
           </tbody>
         </table>
      </div>
</c:if>
<c:if test="${empty param.insuPlanNo }">
	      <div class="current">
           <table class="current_table_1">
              <tbody>
                <tr class="f2">
                  <td>
                    <img src="./images/current_1.jpg">
                  </td>
                  <td class="current_table_1_td">
                    <img src="images/current_1.png">&nbsp;您现在的位置：&nbsp;
                      <span style=" color:#136bab; ">产品管理
                         <span style="padding:0 5px; font-weight:bold; line-height:28px;">&gt;</span>方案配置
                         <span style="padding:0 5px; font-weight:bold; line-height:28px;">&gt;</span>投保方案新增
                      </span>
                  </td>
                  <td><img src="./images/current_3.jpg"></td>
              </tr>
           </tbody>
         </table>
      </div>
</c:if>
	     
			<form id="inputForm" >
			<input id="agentType" type="hidden"><!--销售类型  -->
	        <table class="table_05">
	              <tbody>
		              <tr>
			              <c:if test="${not empty param.insuPlanNo}">
			                  <td colspan="4" style=" font-size:12px; font-weight:bold; text-align:left;color:#3876bf; line-height:17px; background-image:url(images/centent_1.jpg)">投保方案编辑</td>
			              </c:if>
			              <c:if test="${empty param.insuPlanNo}">
			                  <td colspan="4" style=" font-size:12px; font-weight:bold; text-align:left;color:#3876bf; line-height:17px; background-image:url(images/centent_1.jpg)">投保方案新增</td>
			              </c:if>
		              </tr>
		    		  <tr>
		                  <th width="10%">投保方案号：</th>
		                  <td width="40%"><input name="insu_plan_no" id="insu_plan_no" type="text" readonly="readonly" style=" background-color: #ccc;" class="input_text"><span class="red">*</span></td>
		                  <th width="10%">投保方案名称：</th>
		                  <td width="40%"><input id="insu_plan_name" type="text"  class="input_text" ><span class="red">*</span></td>
		              </tr>
		              <tr>
		                  <th width="10%">产品编号：</th>
		                  <td width="40%">
		                  	<input name="planCode" id="prodInstCode" type="text" readonly="readonly" style=" background-color: #ccc;" class="input_text"><span class="red">*</span>&nbsp;
		                  	<c:if test="${empty insuPlanNo}">
		                  		<input type="button"  class="input_button_2" id="searchProdBtn" value="请选择" onClick="openProdDiv(1,this)"/>
		                  	</c:if>
		                  	<c:if test="${not empty insuPlanNo}">
		                  		<input type="button" disabled="disabled" id="searchProdBtn" value="请选择" onClick="openProdDiv(1,this)"/>
		                  	</c:if>
		                  </td>
		                  <th width="10%">合作伙伴代码：</th>
		                  <td width="40%">
		                  	<input name="instCode" id="instCode" type="text" readonly="readonly" style=" background-color: #ccc;" class="input_text"><span class="red">*</span>&nbsp;
		                  	<c:if test="${empty insuPlanNo}">
		                  		<input type="button"  class="input_button_2" id="searchPartnerBtn" value="请选择" onClick="openThisDiv('tradPartnerDiv',1,this)"/>
		                  	</c:if>
		                  	<c:if test="${not empty insuPlanNo}">
		                  		<input type="button" disabled="disabled"  id="searchPartnerBtn" value="请选择" onClick="openThisDiv('tradPartnerDiv',1,this)"/>
		                  	</c:if>
		                  </td>
		              </tr>
		              <tr id="qudaoandlaiyuan01">
		                  <th>归属渠道：</th>
		                  <td>
			                  <select id="channelCodeQD" name="channle_code" class="select_1 valid" style="visibility: visible;">
			                  		<option value="">-----请选择-----</option>
			                  		<c:forEach var ="btcList" items="${btcList}">
			                  			<option value="${btcList.code}">${btcList.codeName}</option>
			                  		</c:forEach>
			                  </select><span class="red">*</span>
		                  </td>
		                  <th>渠道类型：</th>
		                  <td>
			                  <select id="channelType"  class="select_1 valid" style="visibility: visible;">
		                  		<option value="">-----请选择归属渠道-----</option>
		                  		<c:forEach var ="channelList" items="${channelList}">
		                  			<option value="${channelList.code}">${channelList.codeName}</option>
		                  		</c:forEach>
		                  	  </select><span class="red">*</span>
		                  </td>
		              </tr>
		              <tr id="qudaoandlaiyuan02">
		              	  <th>新业务来源：</th>
		                  <td>
		                  	  <select id="newBsnsType"  class="select_1 valid" style="visibility: visible;" name="Ssss">
		                  		<option value="">-----请选择渠道类型-----</option>
		                  		<c:forEach var ="newBSList" items="${newBSList}">
		                  			<option value="${newBSList.code}">${newBSList.codeName}</option>
		                  		</c:forEach>
		                  	  </select><span class="red">*</span>
		                  </td>
		                  <th>原业务来源：</th>
		                  <td>
		                  	  <select id="bsnsType" class="select_1 valid" style="visibility: visible;">
		                  		<option value="">-----请选择-----</option>
		                  		<c:forEach var ="oldBSList" items="${oldBSList}">
		                  			<option value="${oldBSList.code}">${oldBSList.codeName}</option>
		                  		</c:forEach>
		                      </select><span class="red">*</span>
		                  </td>
		              </tr>
		              <tr>
		                  <th id="deptCode101">出单机构：</th>
		                  <td id="deptCode102">
		                  	<input id="dptCode"  type="text" readonly="readonly" style=" background-color: #ccc;" class="input_text"><span class="red">*</span>&nbsp;
		                  	<input type="button"  class="input_button_2" id="searchDeptBtn" value="请选择" onClick="openDeptDiv(1,this)"/>
		                  </td>
		                  <th>手续费比例：</th>
		                  <td>
		                  	<input name="comm_rate" id="comm_rate" type="text"  class="input_text" onKeyUp="clearNoNum(event,this)" onBlur="checkNum(this)">
		                  	<span class="red">*</span>&nbsp;<span id="commRateSpan" class="blue"></span>
		                  </td>
		              </tr>
<!-- --------------------------根据产品销售方式的不同改变以下内容-------------------------------------- -->
		              <!--agentType1  合作伙伴代理   -->
		              <tr id="agentType101">
		                  <th>代理人代码：</th>
		                  <td><input name="agent_no" id="agent_no" type="text"  class="input_text"><span class="red">*</span></td>
		                  <th>代理协议号：</th>
		                  <td><input name="protocol_no" id="protocol_no" type="text" class="input_text"><span class="red">*</span></td>
		              </tr>
		              <tr id="agentType102">
		                  <th>服务代码：</th>
		                  <td><input name="service_code" id="service_code" type="text"  class="input_text"><span class="red">*</span></td>
		                  <th>业务员代码：</th>
		                  <td><input name="emp_no" id="emp_no" type="text" class="input_text"><span class="red">*</span></td>
		              </tr>
		              <tr id="agentType103">
		                  <th>团队代码：</th>
		                  <td><input name="team_code" id="team_code" type="text"  class="input_text"><span class="red">*</span></td>
		                  <th>团队名称：</th>
		                  <td><input name="team_name" id="team_name" type="text" class="input_text"><span class="red">*</span></td>
		              </tr>
		              <!--agentType3   个人代理   -->
		              <tr id="agentType301" style="display:none">
		              	<c:if test="${not empty param.insuPlanNo }">
		                  <th>个人销售业务信息:</th>
		                  <td colspan="3"><input type="button" onclick="openAgentType3Div(1,this)" value="配置个人销售业务信息"/></td>
		              	</c:if>
		              	<c:if test="${empty param.insuPlanNo }">
		                  <th>个人销售业务信息:</th>
		                  <td colspan="3"><input type="button" disabled="disabled" onclick="openAgentType3Div(1,this)" value="配置个人销售业务信息"/></td>
		              	</c:if>
		              </tr>
		              <c:if test="${not empty param.insuPlanNo }">
					  <tr id="agentType302" style="display:none">
		                  <td colspan="4">
		                  	<div style="width:1100px; height:auto; overflow:scroll;">
		                  		<table id="agentType3Table" style="width:1600px;">
			                  		<thead>
										<tr style="background-color: C0C0C0;">
						                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">用户名</th>
						                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">姓名</th>
						                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">出单机构</th>
						                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">服务代码</th>
						                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">业务员代码</th>
						                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">单证领用人</th>
						                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">团队代码</th>
						                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">归属渠道</th>
						                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">渠道类型</th>
						                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">新业务来源</th>
						                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">原业务来源</th>
						                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">代理人编码</th>
						                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">代理协议号</th>
						                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">手续费比例</th>
						              	</tr>
									</thead>
									<tfoot>
										<tr>
						                  <td colspan="14">
						                  	<div id="agentType3TablePageDIV" class="page"></div>
						                  </td>
						              	</tr>
									</tfoot>
									<tbody>
						            </tbody>
			                  	</table>
							</div>
		                  </td>
		              </tr>
		              </c:if>	
		              <!--agentType4   总对总代理   -->
		              <tr id="agentType401" style="display:none">
		              	<c:if test="${not empty param.insuPlanNo }">
		                  <th>总对总销售业务信息:</th>
		                  <td colspan="3"><input type="button" onclick="openAgentType4Div(1,this)" value="配置总对总销售业务信息"/></td>
		              	</c:if>
		              	<c:if test="${empty param.insuPlanNo }">
		                  <th>总对总销售业务信息:</th>
		                  <td colspan="3"><input type="button" disabled="disabled" onclick="openAgentType4Div(1,this)" value="配置总对总销售业务信息"/></td>
		              	</c:if>
		              </tr>
		              <c:if test="${not empty param.insuPlanNo }">
					  <tr id="agentType402" style="display:none">
		                  <td colspan="4">
		                  	<div style="width:1100px; height:auto; overflow:scroll;">
			                  	<table id="agentType4Table" style="width:1700px;">
			                  		<thead>
										<tr style="background-color: C0C0C0;">
						                   <th style="width:100px;text-align: center;">网点代码</th>
			                  			   <th style="width:100px;text-align: center;">网点名称</th>
			                               <th style="width:80px;text-align: center;">用户名</th>
			                               <th style="width:80px;text-align: center;">姓名</th>
			                               <th style="width:80px;text-align: center;">区域代码</th>
			                               <th style="width:80px;text-align: center;">出单机构</th>
			                               <th style="width:80px;text-align: center;">服务代码</th>
			                               <th style="width:80px;text-align: center;">业务员代码</th>
			                               <th style="width:80px;text-align: center;">单证领用人 </th>
			                                <th style="width:80px;text-align: center;">团队代码 </th>
			                                <th style="width:90px;text-align: center;">归属渠道</th>
					                        <th style="width:90px;text-align: center;">渠道类型</th>
					                        <th style="width:100px;text-align: center;">业务来源</th>
					                        <th style="width:100px;text-align: center;">原业务来源</th>
			                                <th style="width:100px;text-align: center;">代理人编码</th>
			                                <th style="width:100px;text-align: center;">代理协议号</th>
			                                <th style="width:80px;text-align: center;">手续费比例 </th>
						              	</tr>
									</thead>
									<tfoot>
										<tr>
						                  <td colspan="15">
						                  	<div id="agentType4TablePageDIV" class="page"></div>
						                  </td>
						              	</tr>
									</tfoot>
									<tbody>
						            </tbody>
			                  	</table>
		                  	</div>
		                  </td>
		              </tr>
		              </c:if>
<!-- --------------------------根据产品销售方式的不同改变以上内容-------------------------------------- -->
		              <tr>
		                  <th>投保人编码：</th>
		                  <td><div style="float:left;  height: 45px ;width:43%;"><select id="applicant_no" class="select_1 valid" style="visibility: visible;"><option value="0" >0</option></select></div><div style="height: 30px ;width:55%;float: left; "><span class="red">*</span><span style="color: blue;padding-left: 15px;">投保时需录入投保人（如自然人投保）时选0，投保人默认为合作伙伴时选编码</span></div></td>
<!-- 		                  <td><input name="applicant_no" id="applicant_no"  type="text" readonly="readonly" style=" background-color: #ccc;"  class="input_text"><span class="red">*</span></td> -->
		                  <th>是否见费出单：</th>
		                  <td><select id="isSeeMoney" onchange="SeeMoneyChange()" class="select_1 valid" style="visibility: visible;"><option value="2">否</option><option value="1">是</option></select></td>
		                  
		              </tr>
		             <!--  -------------刘 -->
		              <tr>
		                  <th>状态：</th>
		                  <td><select name="state" id="state" class="select_1 valid" style="visibility: visible;"><option value="0">无效</option><option value="1">有效</option></select></td>
		                  <th>是否电子保单：</th>
		                  <td>
		                  		<div id="Download_left" style="float: left;width: 15%"><select id="isEpolicy" class="select_1 valid" onchange="IsEpolicyChange()" style="visibility: visible; width: 60px"><option value="N">否</option><option value="Y">是</option></select></div>
		                  		<div id="Download_right" style="float: left;display: none;">
									下载方式：<select id="DownloadWay" class="select_1 valid" style="visibility: visible;;width: 100px" onchange='downloadWayChange()'><option value="0">实时电子保单</option><option value="1">影像系统获取</option></select>		                  		
		                  			<span style="display: none;" id='fileTypeSpan'>文件方式：
		                  			<select id="fileType" class="select_1 valid" style="visibility: visible;width: 80px;">
		                  				<c:forEach var ="fileType" items="${fileTypes}">
			                  				<option value="${fileType.code}">${fileType.codeName}</option>
			                  			</c:forEach>
		                  			</select>
	                  			</span>		
		                  		</div>	
		                  </td>
		              </tr>
<!-- -----------------------------------新增字段 开始 -------------------------------------------------------------->
		              <tr id="poolColumns1" style="display:none">
		                  <th>保险公司：</th>
		                  <td>
		                  	<select id="poolInsureCompany" class="select_1 valid" style="visibility: visible;">
		                  		<option value="0" >--------请选择--------</option>
			                  	<c:forEach var="company" items="${companyList}">
			                  		<option value="${company.code}">${company.codeName}</option>
			                  	</c:forEach>
		                  	</select><span class="red">*</span>
		                  </td>
		                  <th>共保协议：</th>
		                  <td><select id="poolProcotol" class="select_1 valid" style="visibility: visible;"><option value="0" >--------请选择--------</option><option value="1">主共协议</option><option value="2">从共协议</option></select><span class="red">*</span></td>
		              </tr>
		              <tr id="poolColumns2" style="display:none">
		                  <th>共保协议号：</th>
		                  <td><input id="poolProcotolNo"  type="text" class="input_text"><span class="red">*</span></td>
		                  <th>出单标志：</th>
		                  <td><select id="poolIssueFlag" class="select_1 valid" style="visibility: visible;"><option value="2">不出单</option><option value="1">出单</option></select><span class="red">*</span></td>
		              </tr>
		              <tr id="poolColumns3" style="display:none">
		                  <th>代理、经纪费：</th>
		                  <td><input id="poolAgentRate"  type="text" class="input_text" onKeyUp="clearNoNum(event,this)" onBlur="checkNum(this)"></td>
		                  <th>共保费率：</th>
		                  <td><input id="poolRate"  type="text" class="input_text">&nbsp;‰</td>
		              </tr>
		              <tr id="poolColumns4" style="display:none">
		                  <th>出单费：</th>
		                  <td colspan="3"><input id="poolInsureAmount"  type="text" class="input_text" onKeyUp="clearNoNum(event,this)" onBlur="checkNum(this)"></td>
		              </tr>
		              <tr id="poolColumns5" style="display:none">
		                  <th>共保角色：</th>
		                  <td colspan="3">
		                  	<select id="poolRole" class="select_1 valid" style="visibility: visible;">
		                  		<option value="0" >--------请选择--------</option>
			                  	<c:forEach var="role" items="${roleList}">
			                  		<option value="${role.code}">${role.codeName}</option>
			                  	</c:forEach>
		                  	</select><span class="red">*</span>
		                  </td>
		              </tr>
<!------------------------------------- 新增字段 结束 ---------------------------------------------------------------------------->
		              <tr>
		                  <th>是否打印单证：</th>
		                  <td>
		                  	<select id="isPrintCard" onchange="checkPrintCard()" class="select_1" style="visibility: visible;">
		                  		<option value="">----请选择----</option>
		                  		<option value="0">是</option>
		                  		<option value="1">否</option>
		                  	</select><span class="red">*</span>
		                  </td>
		                  <th>单证类型：</th>
		                  <td>
		                  	<div style="float: left;">
		                  		<input id="cardType" type="text" readonly="true" style=" background-color: #ccc;" class="input_text"><span class="red">*</span>
		                  	</div>
		                  	<div id="cardApplicant_div" style="float: left;">
		                  		单证领用人：<input id="cardApplicant" type="text" readonly="true" style=" background-color: #ccc; width:100px" class="input_text"><span class="red">*</span>
		                  	</div>
		                  </td>
		              </tr>
		              <tr>
		              	  <th>是否发送承保短信：</th>
		                  <td>
		                  	<div style="float: left; width:18%;">
		                  		<select name="is_message" onchange="checkIsMessage()" id="is_message" class="select_1 valid" style="visibility: visible;width:95%;"><option value="N">否</option><option value="Y">是</option></select>
		                  	</div>
		                  	<div id="messageReceiverDiv"  style="float: left;display:none;width:35%;">
		                  		接收人：<select name="messageReceiver"  id="messageReceiver" class="select_1 valid" style="visibility: visible;width:65%;"><option value="">----请选择----</option><option value="0">投保人</option><option value="1">被保人</option></select>
		                  	</div>
		                  	<div id="smsTemplateDiv"  style="float: left;display:none;width:47%;">
		                  		短信模板：
		                  		<select name="smsTemplate" id="smsTemplate" onchange="changeIsMessageTemplate()"  class="select_1 valid" style="visibility: visible;width:60%;">
		                  			<option value="">----请选择----</option>
		                  			<c:forEach var ="messageList" items="${messageList}">
		                  				<option value="${messageList.smsTemplateCode}">${messageList.smsTemplateName}</option>
		                  			</c:forEach>
		                  		</select>
		                  	</div>
		                  </td>
					  	  <th>是否回执：</th>
		                  <td>
		                  <div style="float: left;">
		                  	<select name="is_receipt" id="is_receipt" onchange="chooseReceiptType()" class="select_1 valid" style="visibility: visible;"><option value="N">否</option><option value="Y">是</option></select>&nbsp;&nbsp;
		                  </div>
			              <div id="isOrNotDisplayReceiptTypeDiv"  style="float:left;display:none;">
			              	回执类型：<select id = "receiptType" class="select_1 valid" style="visibility: visible; width: 110px;">
			                    <c:forEach var ="receiptTypeLsCode" items="${receiptTypeLs}">
				                	<option value="${receiptTypeLsCode.code}">${receiptTypeLsCode.codeName}</option>
				                </c:forEach>
			                  </select>
			              </div>
		                  </td>
					  </tr>
					  <tr>
					  		<th>是否发送电子发票：</th>
					  		<td><select id="isEpolicyInvoice" class="select_1 valid" style="visibility: visible;"><option value="2">否</option><option value="1">是</option></select></td>	
					  		<th>是否开通支付平台：</th>
					  		<td><select id="isDredgePay" class="select_1 valid" disabled="disabled" style="visibility: visible; background-color: #ccc"><option value="1">是</option><option value="2">否</option></select></td>			
					  </tr>
					  <tr>
					  		<th>是否发送电子邮件：</th>
					  		<td><select id="isEpolicyMali" onchange="CheckedSendMail()" class="select_1 valid" style="visibility: visible;"><option value="2">否</option><option value="1">是</option></select></td>	
					  		
					  		<th id="sendAccessory" style="display: none">附件发送：</th>
					  		<td id="sendAccessoryTd" style="display: none">
					  			<c:if test="${not empty Accessorylist}">
					  				<c:forEach items="${Accessorylist}" var="acc">
					  					<input type="checkbox" name="SendAccessoryBox" id="SendAccessoryBox"  value="${acc.code}"> <span style="margin-left: 5px">${acc.codeName}</span>
					  				</c:forEach>
					  			</c:if>
					  			<c:if test="${not empty AccessoryEditlist}">
					  				<c:forEach items="${AccessoryEditlist}" var="acc">
					  					<input type="checkbox" name="SendAccessoryBox" id="SendAccessoryBox"  value="${acc.code}"> <span style="margin-left: 5px">${acc.codeName}</span>
					  				</c:forEach>
					  			</c:if>
					  		</td>			
					 
					  </tr>
					  <tr>
					  	<th>是否发送注销短信：</th>
		                  <td>
		                 	  <div style="float: left;width:18%;">
		                  		<select name="isCancelMessage" id="isCancelMessage" onchange="changeIsCancelMessage()" class="select_1 valid" style="visibility: visible;width:95%;">
			                  		<option value="N">否</option>
			                  		<option value="Y">是</option>
		                  		</select>
		                  	  </div>
		                  	  <div id="cancelReceiverDiv"  style="float: left;display:none;width:35%;">
		                  		接收人：<select name="cancelReceiver"  id="cancelReceiver" class="select_1 valid" style="visibility: visible;width:65%;"><option value="">----请选择---</option><option value="0">投保人</option><option value="1">被保人</option></select>
		                  	  </div>
		                  	  <div id="cancelTemplateDiv"  style="float: left;display:none;width:47%;">
		                  		短信模板：
		                  		<select name="isCancelTemplate"  id="isCancelTemplate" onchange="changeIsCacelTemplate()" class="select_1 valid" style="visibility: visible;width:60%;">
		                  			<option value="">----请选择----</option>
		                  			<c:forEach var ="cacelList" items="${cacelList}">
		                  				<option value="${cacelList.smsTemplateCode}">${cacelList.smsTemplateName}</option>
		                  			</c:forEach>
		                  		</select>
			                  </div>
		                  </td>
					  </tr>
					 
					  <tr  id="messageTemplateTr" style="display:none">
		                  <th>承保短信模板配置：</th>
		                  <td colspan="3"><textarea name="messageTemplate" id="messageTemplate" cols="" rows="5" class="textarea_1" style="resize:none;"></textarea><span class="red">*</span></td>
	              	  </tr>
	              	  <tr id="cancelTemplateTr" style="display:none">
		                  <th>注销短信模板配置：</th>
		                  <td colspan="3"><textarea name="cancelTemplate" id="cancelTemplate" rows="5" class="textarea_1" style="resize:none;"></textarea><span class="red">*</span></td>
	             	 </tr>
	              	  <tr id="MailTemplateTr" style="display: none;">
	              	  		<th>邮件模板配置：</th>
	              	  		<td colspan="3"><textarea name="MailTemplate" id="MailTemplate" rows="5" cols="" class="textarea_1" style="resize:none"></textarea><span class="red">*</span> </td>
	              	  </tr>
		              <tr>
		                  <th>特别约定：</th>
		                  <td colspan="3"><textarea name="special_arran" id="special_arran" cols="" rows="5" class="textarea_1" style="resize:none;"></textarea></td>
	              	  </tr>
	              	  <tr>
		                  <th>温馨提示：</th>
		                  <td colspan="3"><textarea name="reminder" id="reminder" cols="" rows="5" class="textarea_1" style="resize:none;"></textarea></td>
	              	  </tr>
	           	  </tbody>
	         </table> 
	         <div align="center">
	             <input class="input_button_3" name="" id="sbtn" type="button" onclick="checkAndExcute('add')" value="保存">&nbsp;&nbsp;
		         <input class="input_button_3" name="" type="button" value="返回" onclick="goBack()">
	         </div>
	         </form>
	      </div>    
</div>

	
		<!--   	产品 DIV 默认隐藏-->
  		<div id="prodDiv"  style="display:none;width:80%;">
			<input type="hidden" id="row_num" name="row_num" value="0"/>
				<div class="table_title_div">
					<table class="table_title" style='width:100%;height:20px;'>
						<tr>
						<td width="10%"></td>
						<td width="80%" id="interfaceName"></td>
						<td width="10%" align="right"><img src="./images/closedown.gif" alt="关闭"  onclick="closeCurrentDIV('prodDiv')"/></td>
						</tr>
					</table>
				</div>
	
			<!-- 修改id 名 -->
			<table class="table_02" id="addtempletTable" align="center" >
				<tbody>
				<tr>
				<td>
					<table class="search_table">
					<tr height="30px" >
							<td style="border:0px;text-align: right;">交易系统产品代码：</td>
							<td style="border:0px;text-align: left;">
								<input name="txt3"  id="prodcode"  type="text" class="input_text" value="" style="width:120px;">
							</td>
							<td style="border:0px;text-align: right;">
								交易系统产品描述：
							</td>
							<td style="border:0px;text-align: left;"><input name="txt3" id="proddesc"  type="text" class="input_text" value="" style="width:120px;"></td>
					</tr>
					<tr height="30px" >
							<td style="border:0px;text-align: right;">定义起期：</td>
							<td style="border:0px;text-align: left;">
								<input id="startDate" onkeydown="false" onclick="showCalendar('startDate','y-mm-dd');$('.calendars').css('z-index',20000);" class="input_time" type="text" style="width:120px;"/>
							</td>
							<td style="border:0px;text-align: right;">
							定义止期：
							</td>
							<td style="border:0px;text-align: left;">
								 <input id="endDate" onkeydown="false" onclick="showCalendar('endDate','y-mm-dd');$('.calendars').css('z-index',20000);" class="input_time" type="text" style="width:120px;"/>
								 &nbsp;&nbsp;&nbsp;&nbsp;
								<input type="button"  class="input_button_1" id="searchBtn" value="查询" onClick="queryTradProdInst(1)"/>
							</td>
					</tr>
				</table>
				</td></tr>
					<tr>
						<td>
							<!-- 修改数据table名 -->
							<table id="productTable"  class="content_table_1">
								<thead>
									<tr class="f1">
					                  <th style="width:5%">选择</th>
					                  <th style="width:45%">交易系统产品代码</th>
					                  <th style="width:50%">交易系统产品描述</th>
					              	</tr>
								</thead>
								<!-- 修改tobody 默认为空 -->
								<tbody>
								</tbody>
							</table>
							<!-- 修改分页编码id 名  默认为空-->
							<div id="productPageDIV" class="page">
							</div>
						</td>
					</tr>
				</tbody>
			</table>
			<div align="center" >
			 <input class="input_button_3" name="" type="button" onclick="chooseProd()" value="确定">&nbsp;&nbsp;
	         <input class="input_button_3" name="" type="button" onclick="closeCurrentDIV('prodDiv')" value="取消">
			</div>
	   </div>
	
	
	<!--   	选择 合作伙伴 div-->
  	<div id="tradPartnerDiv" style="display:none;width:80%;">
  		<input type="hidden" id="row_num" name="row_num" value="0"/>
			<div class="table_title_div">
					<table class="table_title" style='width:100%;height: 20px;'>
						<tr>
						<td width="10%"></td>
						<td width="80%" id="interfaceName"></td>
						<td width="10%" align="right"><img src="./images/closedown.gif" alt="关闭"  onclick="closeCurrentDIV('tradPartnerDiv')"/></td>
						</tr>
					</table>
			</div>
		<table class="table_02" id="table" style="height:180px;" align="center">
			<tr>
				<td>
					<table class="search_table">
						<tr height="30px">
							<td colspan="3" style="text-align:center">
							 合作伙伴代码：<input name="txt3"  id="channelCode"  type="text" class="input_text" value="" >&nbsp;&nbsp;
							 合作伙伴名称：<input name="txt3" id="channelName"  type="text" class="input_text" value="">&nbsp;&nbsp;
								       <input type="button"  class="input_button_1" id="searchBtn" value="查询" onClick="queryTradPartners(1)"/>
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td>
					<table id="TradPartnerTable"  class="content_table_1">
						<thead>
							<tr class="f1">
			                  <th style="width:5%">选择</th>
			                  <th style="width:10%">合作伙伴代码</th>
			                  <th style="width:20%">合作伙伴名称</th>
			              	</tr>
						</thead>
						<tbody>
						</tbody>
					</table>
					<div id="TradPartnerPageDIV"  class="page"></div>
				</td>
			</tr>
		</table>
		<div align="center" >
		  <input type="button" id="saveRoleBtn" value="确定" onclick="choosePartner()" class="input_button_3"/>&nbsp;&nbsp;&nbsp;
		  <input type="button" value="取消" onclick="closeCurrentDIV('tradPartnerDiv')" class="input_button_3"/>
		</div>
	</div>	
	
	
	<!--   	机构 DIV 默认隐藏-->
	<div id="deptDiv" style="display:none;width:80%;">
  		<input type="hidden" id="row_num" name="row_num" value="0"/>
			<div class="table_title_div">
					<table class="table_title" style='width:100%;height: 20px;'>
						<tr>
						<td width="10%"></td>
						<td width="80%" id="interfaceName"></td>
						<td width="10%" align="right"><img src="./images/closedown.gif" alt="关闭"  onclick="closeCurrentDIV('deptDiv')"/></td>
						</tr>
					</table>
			</div>
		<table class="table_02" id="table" style="height:180px;" align="center">
			<tr>
				<td>
					<table class="search_table">
						<tr height="30px">
							<td colspan="3" style="text-align:center">
							 出单机构代码：<input name="txt3"  id="deptcode"  type="text" class="input_text" value="" >&nbsp;&nbsp;
							 出单机构名称：<input name="txt3" id="deptcnname"  type="text" class="input_text" value="">
								       <input type="button"  class="input_button_1" id="searchBtn" value="查询" onClick="queryCoreDept(1)"/>
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td>
					<table id="deptTable"  class="content_table_1">
						<thead>
							<tr class="f1">
			                  <th style="width:5%">选择</th>
			                  <th style="width:45%">出单机构代码</th>
			                  <th style="width:50%">出单机构名称</th>
			              	</tr>
						</thead>
						<tbody>
						</tbody>
					</table>
					<div id="deptPageDIV"  class="page"></div>
				</td>
			</tr>
		</table>
		<div align="center" >
		  <input type="button" id="saveRoleBtn" value="确定" onclick="chooseDept()" class="input_button_3"/>&nbsp;&nbsp;&nbsp;
		  <input type="button" value="取消" onclick="closeCurrentDIV('deptDiv')" class="input_button_3"/>
		</div>
	</div>
	
	 
	
	<!--配置个人销售业务信息 div-->
  	<div id="agentTypeDiv3" style="display:none;width:1000px; height:450px; overflow:scroll;">
		<div class="table_title_div" style="width: 1600px">
			<table class="table_title" style='width:1600px;height: 20px;'>
				<tr>
				<td width="120px"></td>
				<td width="1460px" id="interfaceName"></td>
				<td width="20px" align="right"><img src="./images/closedown.gif" alt="关闭"  onclick="closeAgentTypeDiv('agentTypeDiv3')"/></td>
				</tr>
			</table>
		</div>
		<table class="table_02" id="table" style="width:1550px;" align="center">
			<tr>
				<td>
					<table class="search_table">
						<tr height="30px">
							<td colspan="10" style="text-align:center">
							<!-- 表单号不为空即编辑时显示配置状态 -->
							<c:if test="${not empty insuPlanNo}">
								配置状态：<select id="confStatus"><option value="ALL">全部</option><option value="YES">已配置</option><option value="NO">未配置</option></select>&nbsp;&nbsp;
							</c:if>
							<c:if test="${empty insuPlanNo}">
								<input id="confStatus" type="hidden"  value="ALL">
							</c:if> 
							 用户名：<input id="agentCode" type="text" class="input_text" value="">&nbsp;&nbsp;
							 姓名：<input id="agentName" type="text" class="input_text" value="">&nbsp;&nbsp;
								<input type="button"  class="input_button_1" id="searchBtn" value="查询" onClick="queryConfProxyInfo3(1)"/>
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td>
					<table id="agentTypeDiv3Table"  class="content_table_1">
						<thead>
							<tr class="f1">
			                  <th style="width:40px"><input id="agentTypeDiv3CheckAll" type="checkbox"></th>
			                  <th style="width:100px">用户名</th>
			                  <th style="width:100px">姓名</th>
			                  <th style="width:100px">出单机构</th>
			                  <th style="width:100px">服务代码</th>
			                  <th style="width:100px">业务员代码</th>
			                  <th style="width:100px">单证领用人</th>
			                  <th style="width:100px">团队代码 </th>
			                  <th style="width:120px">归属渠道</th>
					          <th style="width:120px">渠道类型</th>
					          <th style="width:130px">新业务来源</th>
					          <th style="width:130px">原业务来源</th>
			                  <th style="width:100px">代理人编码 </th>
			                  <th style="width:100px">代理协议号</th>
			                  <th style="width:100px">手续费比例 </th>
			              	</tr>
						</thead>
						<tbody>
						</tbody>
					</table>
					<div id="agentTypeDiv3Page"  class="page"></div>
				</td>
			</tr>
		</table>
		<div align="center" >
		  <input type="button" id="saveRoleBtn" value="保存" onclick="saveChooseAgentType3()" class="input_button_3"/>&nbsp;&nbsp;&nbsp;
		  <input type="button" value="取消" onclick="closeAgentTypeDiv('agentTypeDiv3')" class="input_button_3"/>
		</div>
	</div>
	
	<!--配置总对总代理信息 div-->
  	<div id="agentTypeDiv4" style="display:none;width:1000px; height:450px; overflow:scroll;">
		<div class="table_title_div" style="width: 1640px">
			<table class="table_title" style='width:1640px;height: 20px;'>
				<tr>
				<td width="120px"></td>
				<td width="1460px" id="interfaceName"></td>
				<td width="60px" align="right"><img src="./images/closedown.gif" alt="关闭"  onclick="closeAgentTypeDiv('agentTypeDiv4')"/></td>
				</tr>
			</table>
		</div>
		<table class="table_02" id="table" style="width:1640px;" align="center">
			<tr>
				<td>
					<table class="search_table">
						<tr height="30px">
							<td colspan="10" style="text-align:center">
							<!-- 表单号不为空即编辑时显示配置状态 -->
							<c:if test="${not empty insuPlanNo}">
								配置状态：<select id="confStatus4"><option value="ALL">全部</option><option value="YES">已配置</option><option value="NO">未配置</option></select>&nbsp;&nbsp;
							</c:if>
							<c:if test="${empty insuPlanNo}">
								<input id="confStatus4" type="hidden"  value="ALL">
							</c:if> 
							 网点代码：<input id="branch" type="text" class="input_text" value="">&nbsp;&nbsp;
							 网点名称：<input id="branchName" type="text" class="input_text" value="">&nbsp;&nbsp;
								<input type="button"  class="input_button_1" id="searchBtn" value="查询" onClick="queryConfProxyInfo4(1)"/>
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td>
					<table id="agentTypeDiv4Table"  class="content_table_1">
						<thead>
							<tr class="f1">
			                  <th style="width:40px"><input id="agentTypeDiv4CheckAll" type="checkbox"></th>
			               	  <th style="width:90px">网点代码</th>
			                  <th style="width:110px">网点名称</th>
			                  <th style="width:90px">用户名</th>
			                  <th style="width:90px">姓名</th>
			                  <th style="width:90px">区域代码</th>
			                  <th style="width:90px">出单机构</th>
			                  <th style="width:90px">服务代码</th>
			                  <th style="width:90px">业务员代码</th>
			                  <th style="width:90px">单证领用人 </th>
			                  <th style="width:100px">团队代码 </th>
			                  <th style="width:100px">归属渠道</th>
					          <th style="width:100px">渠道类型</th>
					          <th style="width:100px">新业务来源</th>
					          <th style="width:100px">原业务来源</th>
			                  <th style="width:90px">代理人编码</th>
			                  <th style="width:90px">代理协议号</th>
			                  <th style="width:90px">手续费比例 </th>
			              	</tr>
						</thead>
						<tbody>
						</tbody>
					</table>
					<div id="agentTypeDiv4Page"  class="page"></div>
				</td>
			</tr>
		</table>
		<div align="center" >
		  <input type="button" id="saveRoleBtn" value="保存" onclick="saveChooseAgentType4()" class="input_button_3"/>&nbsp;&nbsp;&nbsp;
		  <input type="button" value="取消" onclick="closeAgentTypeDiv('agentTypeDiv4')" class="input_button_3"/>
		</div>
	</div>

		
		
</body>
</html>